openbmc
openbmc copied to clipboard
Unable to set hostname through DHCP
Hey!
Sending host-name
option through DHCP is mostly ignored due to how hostname.sh
works:
- OpenBMC boots
- dhclient gets its DHCP lease containing a
host-name
option - dhclient-script sets the hostname using the
hostname
command -
hostname.sh
overrides the hostname with eitherbmc-oob
or with hostname stored in/mnt/data/hostname
and store the result in/mnt/data/hostname
.
Also, if there is no network connectivity on boot:
- OpenBMC boots
- dhclient is unable to get a lease and will go on background
-
hostname.sh
will sets and store it in/mnt/data/hostname
- network connectivity comes back
- dhclient gets a lease and host-name
-
dhclient-script
won't update the hostname as one is already set
In case systemd is used, this is the same logic in networkd, except the hostname seems to be set even when a hostname already is set (I didn't test).
I would suggest to not change hostname if one already exists (as per hostname
command). This wouldn't solve the second case, except with systemd.