Re: hostname-mode : short vs fqdn name



On Tue, Apr 07, 2020 at 10:48:28PM +0200, Thomas HUMMEL wrote:
Hello,

I'm trying to figure out how exactly my stateless HPC nodes (CentOS
8.1/NetworkManager-1.20.0) get their hostnames.

As a matter of fact, they can either get a "short" (non fqdn - something
like 'maestro-1000') hostname or a fqdn hostname
(maestro-1000.maestro.pasteur.fr). This is related to the process network is
configured according to the following procedure :

1. node PXE boots the stateless osimage and ends up having a dhcp NM profile
2. a postscript is run on the node which uses NM to create an additional
profile with higher autoconnect priority which main goal is to statically
set the ip address retrieved in step 1.

- if only step 1. is performed  hostname == short name
- if step 1 + 2. are performed, hostname == fqdn

Note :

- DNS is configured on each node, both for forward and reverse zone

- I checked with tcpdump that DHCP option 12 "Host-Name" always stores the
short name (and of course the domain 'maestro.pasteur.fr' in option 15)

- step2 (I guess) puts HOSTNAME=maestro-1000 in /etc/sysconfig/network

AFAIK, NetworkManager doesn't do that.

- node never have a /etc/hostname file

- no hostname-mode is specified in NetworkManager.conf

- finally, when step 1+2 are performed, I can see:

Apr 07 20:13:19 maestro-1000 systemd-hostnamed[14516]: Changed host name to
'maestro-1000'
Apr 07 20:13:33 maestro-1000.maestro.pasteur.fr systemd-hostnamed[14516]:
Changed host name to 'maestro-1000.maestro.pasteur.fr'

which I reckon matches step1 then step2

Here are my questions :

- I am assuming NetworkManager uses systemd-hostnamed when it is in charge
to set the hostname : is this correct ?

Yes, it uses the SetHostname D-Bus call of systemd-hostnamed, which
changes the transient (kernel) hostname.

- I am assuming what I see is related to hostname-mode setting as I didn't
see any hostname or hostnamectl et sethostname call in the postscript.
Playing with its possible valued in NM config, I experienced the following
after step 1+2 :

a) default : what's described above (fqdn)
b) none : hostname == short name
c) dhcp : same as a) (fqdn)

I can elaborate on that like this :

a) as man said NM sets hostname "with the one provided via DHCP", which is
first the short one (step1) then as a static profile is activated, it falls
back to "hostname from the reverse lookup of the IP address" (which DNS
resolves in the fqdn)

Right.


b) : NM just don't play with the transient name and sets a static hostname
coming from /etc/sysconfig/network

NM sets the transient host name. It doesn't know about
/etc/sysconfig/network. The hostname is determined in this way:

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/1.20.0/src/nm-policy.c#L744


c) confuses me as the manual says NM

"will update the transient hostname only with information coming from DHCP"
but with no fallback
So I was expecting after step 2 to have localhost.localdomain or only the
short name but not the fqdn

Or maybe it builds a fqdn from host-name + domain coming from DHCP ?

No, it only takes the short hostname from DHCP.

I don't know why it is setting the FQDN in your case. Could you please
put level=trace in the [logging] section of
/etc/NetworkManager/NetworkManager.conf, disabled journald
ratelimiting, reproduce the issue and attach the journal log of a boot
with hostname-mode=dhcp?

Beniamino


Can you help me figuring out my misunderstanding ?

Thanks for your help

--
Thomas HUMMEL

Attachment: signature.asc
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]