cancel
Showing results for 
Search instead for 
Did you mean: 

Assign hostname to local IP address

hml57
Dabbler
Posts: 20
Registered: ‎08-10-2016

Assign hostname to local IP address

I have a linux fedora box that starts up and with dhcpclient obtains a lease from the router's dhcp server, and the dhcp client is configured to send this to it:

send host-name "myserver"; # added by NetworkManager

option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
option ms-classless-static-routes code 249 = array of unsigned integer 8;
option wpad code 252 = string;

also request rfc3442-classless-static-routes;
also request ms-classless-static-routes;
also request static-routes;
also request wpad;
also request ntp-servers;


however:
1. in the web interface to the router, under My home network/wired, sometimes I see the IPaddress/Ethernetaddress and the name correctly.
2. some other times I see no entry at all for that IP in the list (but the box is still working)

3. at other times, I see "Unknown" in the name instead of the proper hostname

Any ideas?

Thanks

16 REPLIES 16
Anonymous
Not applicable

Re: Assign hostname to local IP address

@hml57 - I don't use Fedora but I am sure you'll need to use a DHCP hook to do this. This link is for Ubuntu but might give you an insight into what's needed.

hml57
Dabbler
Posts: 20
Registered: ‎08-10-2016

Re: Assign hostname to local IP address

I think that was for assigning the box's hostname from the dhcp server's response.
In my case, the router itself shows (through its web interface) a wrong "unknown" hostname.
also, when i query the router's dns, it says it doesn't know about the suggested hostname.

 

the snippet in my initial post is the dhcpclient hook/cfg file and it does get sent to the router, which successfully assigns the hostname to the Ip address it returns, but that just doesn't last forever.

Anonymous
Not applicable

Re: Assign hostname to local IP address

@hml57 - Try adding

also request host-name 

to your .cfg file.

hml57
Dabbler
Posts: 20
Registered: ‎08-10-2016

Re: Assign hostname to local IP address

no luck.

i restarted the box.

then i see on http://192.168.1.254 wired the correct name for my box IP.  i could query the dns server for it too.

then after 30mns, it just became unknown again on the page, and dns too

Anonymous
Not applicable

Re: Assign hostname to local IP address

Well host names doesn’t actually come from DHCP but DNS so you may want to have a look at the router to see if you can assign host names to devices. If it can’t do this then you’ll need to adopt another approach. I assume setting the hostname on the client has no permanent effect?

At the moment I use bind9 for my own DNS which is serious overkilll so much so that I intend to replace it and my DHCP server with dnsmasq running on a Pi with Arch Linux as the OS.

hml57
Dabbler
Posts: 20
Registered: ‎08-10-2016

Re: Assign hostname to local IP address

No but my assumption is that the dhclient that starts at bootup of the box sends the desired hostname to dhcp server on the router which then configures it on the dns server on the router. Otherwise, how would the router show properly the sent hostname initially?

the plusnet router's web interface has no other access to configure the dns server?

Anonymous
Not applicable

Re: Assign hostname to local IP address

I agree so it would appear then that the weakest link here is in fact the Plusnet router, so maybe one of the Plusnet staff can confirm if this facility is supported. So to pre-empt them, what model router do you have?

hml57
Dabbler
Posts: 20
Registered: ‎08-10-2016

Re: Assign hostname to local IP address

sagemcom 2704N is what i read underneath.

hml57
Dabbler
Posts: 20
Registered: ‎08-10-2016

Re: Assign hostname to local IP address

Support staff are notoriously non technical.

1 thing i noted though is that my other windows PC appears fine however. Its name appears in dns and router web interface
So this points back to the linux dhclient doing something different from the windows one

ejs
Aspiring Hero
Posts: 5,442
Thanks: 631
Fixes: 25
Registered: ‎10-06-2010

Re: Assign hostname to local IP address

It's not necessarily solely related to DHCP. The router might also use other protocols such as Windows networking protocols or even UPnP / SSDP to detect device names.

Leaving samba services running just so that the router shows the correct name seems a bit overkill though.

hml57
Dabbler
Posts: 20
Registered: ‎08-10-2016

Re: Assign hostname to local IP address

Well it's not just so the router shows the right name

It's for the router dns server to assign the correct name to the iP that the dhcp server gives to my Linux box.

I don't see a way to do that statically in the router Web interface
hml57
Dabbler
Posts: 20
Registered: ‎08-10-2016

Re: Assign hostname to local IP address

To recap, the windows 7 pc gets its name assigned correctly at the router level and the dns level and stays like that all the time.
The Fedora linux box gets its name assigned correctly for a short period of time (the dhclient sends it to the router), then it disappears.

Is there a next step to investigate more accurately what's going on?

 

Regards,

ejs
Aspiring Hero
Posts: 5,442
Thanks: 631
Fixes: 25
Registered: ‎10-06-2010

Re: Assign hostname to local IP address

If you have a firewall enabled on the Fedora box, configure it to log everything incoming that it blocks. Then you'd be able to see if there's anything that you need to allow through the firewall. Or disable the firewall or change it to allow everything. Maybe then leave wireshark capturing for a while until the problem occurs, which might capture something the router sends that the Fedora box doesn't reply to.

Or you could try running having samba services running and see if they fix it.

DS
Seasoned Champion
Posts: 2,307
Thanks: 504
Fixes: 22
Registered: ‎06-01-2017

Re: Assign hostname to local IP address

I could be missing the something here, but I believe you want to name the device via the routers home network page... (y/n)? Because the router keeps losing it's name (y/n)?

I can't comment on early PN routers, but it is possible on the PNH1 and all BT Home Hub's, so assume it can be done on yours too.

snip of my home network.JPG

Via the home network page, if you get a page similar to the one I've included (though I have removed information from the page prior to posting), then look for your device, click on the text and it should open a new page. From there you can name it anything you like, and this overrides the name the device. You would need to click apply for each device name change.

for example, my YouView-TV box name has been changed from it's default name.