Debian Codegraph @

docs/internal/hostname.md

raw
1 Hostname management
2 ===================
3
4 NetworkManager can update the system hostname via different
5 mechanisms. The following diagram describes the workflow:
6
7 ![Hostname management workflow](hostname.png "Hostname management")
8
9 A few notes on the diagram:
10
11 - if there is a static hostname set in `/etc/hostname`, no action is
12 taken. NetworkManager only manages the transient hostname. See the
13 systemd-hostnamed
14 [documentation](https://www.freedesktop.org/software/systemd/man/latest/org.freedesktop.hostname1.html#Semantics)
15 about the distinction between static and transient hostname.
16
17 - When there is no static hostname set, NetworkManager builds a
18 sorted list of active devices that are eligible for the hostname
19 evaluation. When doing so, the `hostname` setting of the connection
20 active on each device is taken into account. Properties `from-dhcp`
21 and `from-dns-lookup` determine if the two methods must be used for
22 the device; property `only-from-default` determines whether devices
23 without a default route should be considered, and `priority` is
24 used to sort the entries. In case of a tie of the priority, a
25 device with the default route comes first.
26
27 - When evaluating a given device, first NM checks if the device
28 received an hostname via DHCP and then if the first IPv4 and IPv6
29 addresses configured on the interface can be resolved to a name via
30 DNS. The mechanism used to perform the reverse DNS lookup of a
31 specific address is described in the diagram on the right.
32
33 - In the "spawn helper" step, NM starts a separate process that
34 performs the reverse DNS lookup using the NSS services specified
35 (see `man nsswitch.conf`). Service `dns` does the lookup via a DNS
36 query, while `files` returns results from `/etc/hosts`.
37
38 - In case there is no valid result from DHCP or DNS, from any device,
39 if there a valid transient hostname set outside of NetworkManager,
40 that hostname is honored.