How to set hostname on DHCP client?

A forum for general AmigaOS 4.x support questions that are not platform-specific
Post Reply
duga
Posts: 54
Joined: Wed May 27, 2015 7:11 am

How to set hostname on DHCP client?

Post by duga »

Sam460ex
OS 4.1 FE Update 2 including hotfix.

Under Internet settings, under interface ppc460ex_eth the settings are DHCP and the hostname is set to Sam460ex. But when I run asynergyc the hostname is still localhost.

c:ShowNetStatus doesn't show the hostname.
Ranger doesn't show the hostname either.

How do I set the hostname when using DHCP (not static IP)?
User avatar
Raziel
Posts: 1061
Joined: Sat Jun 18, 2011 4:00 pm
Location: a dying planet

Re: How to set hostname on DHCP client?

Post by Raziel »

Go to SYS:DEVS/Internet
Fire up an editor and load in HOSTS
Add your computers IP and the hostname you want to use
e.g.
100.200.300.45 Sam460EX

If you now reboot (or do a network restart) you can ping your own computer with "ping Sam460EX" and it is available on your home LAN
People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
User avatar
nbache
Beta Tester
Beta Tester
Posts: 1614
Joined: Mon Dec 20, 2010 7:25 pm
Location: Copenhagen, Denmark
Contact:

Re: How to set hostname on DHCP client?

Post by nbache »

It's a bit of a drag to have to do this every time your lease changes its IP address though, isn't it? (Hint: the OP uses DHCP, not a static IP address.)

Maybe it can be set in the router?

Best regards,

Niels
duga
Posts: 54
Joined: Wed May 27, 2015 7:11 am

Re: How to set hostname on DHCP client?

Post by duga »

Raziel wrote: Sun Jan 17, 2021 11:26 pm Go to SYS:DEVS/Internet
Fire up an editor and load in HOSTS
Add your computers IP and the hostname you want to use
e.g.
100.200.300.45 Sam460EX

If you now reboot (or do a network restart) you can ping your own computer with "ping Sam460EX" and it is available on your home LAN
As nbache wrote; this is not the method when using DHCP as the IP address is changing from time to time.

Is the host field under the network interface in Internet settings used at all?
User avatar
Raziel
Posts: 1061
Joined: Sat Jun 18, 2011 4:00 pm
Location: a dying planet

Re: How to set hostname on DHCP client?

Post by Raziel »

Argh, missed the whole DHCP thing...it's even mentioned in the OP header... :-/

The HOSTS file is used by Internet prefs, hosts tab (it's unusable slow for me though, since i use a 700kb anti-spam hosts from steven black, which i update automatically on bootup).
It works perfectly fine with any browser and beats every third-party anti-spam plugin by miles, since it's open source.

The loading of Internet Prefs takes up to 5 minutes here, though, due to the sheer size of the file (and it seems that Interprefs prefs reads and checks every line from that file), that's why i never use it, editing everything manually with an editor.
People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 596
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: How to set hostname on DHCP client?

Post by broadblues »

I'm not sure if you can set your hostname on the network with DHCP none of my machines ever show up with name on the routers I've used (though loonix and windozes ones can do it).

To get past this I used to use static IP on my old network setup.

On the new setup, since moving there are many machines with DHCP setting I can't control (gfs laptop, phones etc) I've ended up using the router to fix the ips provided to each machine via the mac address. So it becomes DHCP with fixed IPs .

Then you can add all the local machines known ips to your hosts file
User avatar
nbache
Beta Tester
Beta Tester
Posts: 1614
Joined: Mon Dec 20, 2010 7:25 pm
Location: Copenhagen, Denmark
Contact:

Re: How to set hostname on DHCP client?

Post by nbache »

Edit: The following may not be correct. I'm investigating ...

Edit 2: It should work. See viewtopic.php?p=52309#p52309 below.

v--- Incorrect information ---v
I asked Olaf about it.

Apparently, there is a way in the DHCP protocol to specify the hostname you want, but Roadshow doesn't implement it at this time.

The hostname field in the netinterface specification window in Internet prefs is not used for anything like this, it just sets an environment variable locally
on the machine.
^--- Incorrect information ---^

Best regards,

Niels
Last edited by nbache on Tue Jan 19, 2021 2:05 pm, edited 1 time in total.
duga
Posts: 54
Joined: Wed May 27, 2015 7:11 am

Re: How to set hostname on DHCP client?

Post by duga »

Thanks. Consider this as a feature request then. :)

Host Configuration Parameters Options:
host name
Option Code: 12
User avatar
nbache
Beta Tester
Beta Tester
Posts: 1614
Joined: Mon Dec 20, 2010 7:25 pm
Location: Copenhagen, Denmark
Contact:

Re: How to set hostname on DHCP client?

Post by nbache »

Okay, seems like we found out what the situation is.

It does work already, apparently. Several beta testers are using it (and they are not using a beta version to do it ;-)).

For me, it didn't work in a short test, where I changed one machine to use DHCP with a host name (hitherto unknown). But that was most likely because the router had cached its knowledge of my machine via its MAC address and then assigned the old host name to it.

When I get time to try it again, I'll see if I can remove the machine altogether from the router's list of known devices and then connect it with DHCP and the new name - that should work.

You could try the same thing yourself, if possible.

Best regards,

Niels
duga
Posts: 54
Joined: Wed May 27, 2015 7:11 am

Re: How to set hostname on DHCP client?

Post by duga »

Thank you very much.

Yes, I can via tcpdump see that my Sam460ex actually has a hostname. (Why asynergyc can't see is another story. Maybe it uses gethostid instead of gethostbyname).


From the SDK, for those that are interested:

NOTES
This function will attempt to match the host's IP address, as obtained
by querying the first interface that is online, against the host
database. If that fails, it will attempt to perform a reverse name
resolution. If that fails, it will query the 'HOSTNAME' environment
variable. If that fails, it will return the name "localhost".
Post Reply