(cherry picked from commit543ebef32b) (cherry picked from commit9f09d4d364) (cherry picked from commitff81488583) (cherry picked from commit524febf271) (cherry picked from commitdb4975733b)
1.9 KiB
Hostname management
NetworkManager can update the system hostname via different mechanisms. The following diagram describes the workflow:
A few notes on the diagram:
-
if there is a static hostname set in
/etc/hostname, no action is taken. NetworkManager only manages the transient hostname. See the systemd-hostnamed documentation about the distinction between static and transient hostname. -
When there is no static hostname set, NetworkManager builds a sorted list of active devices that are eligible for the hostname evaluation. When doing so, the
hostnamesetting of the connection active on each device is taken into account. Propertiesfrom-dhcpandfrom-dns-lookupdetermine if the two methods must be used for the device; propertyonly-from-defaultdetermines whether devices without a default route should be considered, andpriorityis used to sort the entries. In case of a tie of the priority, a device with the default route comes first. -
When evaluating a given device, first NM checks if the device received an hostname via DHCP and then if the first IPv4 and IPv6 addresses configured on the interface can be resolved to a name via DNS. The mechanism used to perform the reverse DNS lookup of a specific address is described in the diagram on the right.
-
In the "spawn helper" step, NM starts a separate process that performs the reverse DNS lookup using the NSS services specified (see
man nsswitch.conf). Servicednsdoes the lookup via a DNS query, whilefilesreturns results from/etc/hosts. -
In case there is no valid result from DHCP or DNS, from any device, if there a valid transient hostname set outside of NetworkManager, that hostname is honored.
