facebook / openbmc

OpenBMC is an open software framework to build a complete Linux image for a Board Management Controller (BMC).
632 stars 277 forks source link

Unable to set hostname through DHCP #140

Open vincentbernat opened 3 years ago

vincentbernat commented 3 years ago

Hey!

Sending host-name option through DHCP is mostly ignored due to how hostname.sh works:

  1. OpenBMC boots
  2. dhclient gets its DHCP lease containing a host-name option
  3. dhclient-script sets the hostname using the hostname command
  4. hostname.sh overrides the hostname with either bmc-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:

  1. OpenBMC boots
  2. dhclient is unable to get a lease and will go on background
  3. hostname.sh will sets and store it in /mnt/data/hostname
  4. network connectivity comes back
  5. dhclient gets a lease and host-name
  6. 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.

Armodes commented 3 years ago

+1