NetworkManager does not use transient hostname with internal DHCP client
When using the internal NM DHCP client, a transient hostname will not be sent in the DHCP discover packet. Only a static hostname will. When using dhclient or dhcpcd the transient hostname is used and sent in the DHCP packets (when configured to send this DHCP option).
This is observed when using systemd-hostnamed. When the transient hostname is set and a static hostname is not, /etc/hostname
and uname(2)
will provide the transient hostname (and thus other DHCP clients work as expected). The Hostname
property in org.freedesktop.hostname1
will be the transient hostname while the StaticHostname
property will be blank. The code in src/nm-hostname-manager.c:hostnamed_properties_changed() will only check the latter property.
I suspect the reasoning behind this was based on the belief that the transient hostname could only be a default hostname from the kernel, e.g. "localhost" or a hostname acquired via DHCP. It makes no sense to send the former and it would appear to be unnecessary to send the hostname acquired via DHCP when trying to bring an interface back up.
However, there are other ways the transient hostname can be set. Via DHCP on a different interface. Via an interactive user action. Or, in our case, on an embedded system that sets the hostname based on various rules that involve customer configuration settings, and device type and serial number.