Re: hostname-mode : short vs fqdn name



On Wed, Apr 08, 2020 at 04:18:32PM +0200, Thomas HUMMEL wrote:
Hello, thanks for your answer

On 4/8/20 10:25 AM, Beniamino Galvani wrote:

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

AFAIK, NetworkManager doesn't do that.

Although I saw that it was the postscript which wrote into this file, I
thought NetworkManager was considering it because it is mentionned in man 5
nm-settings-ifcfg-rh

Yes, the file is used for other variables but not for HOSTNAME.


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

Talking about D-Bus, I see this in the begining of all 3 (default, none,
dhcp) traces :

Apr 08 14:53:29 maestro-1000.maestro.pasteur.fr NetworkManager[25235]:
<trace> [1586350409.2521] policy: get-hostname:
"maestro-1000.maestro.pasteur.fr" (from dbus)
Apr 08 14:53:29 maestro-1000.maestro.pasteur.fr NetworkManager[25235]:
<trace> [1586350409.2521] policy: hostname-original: set to
"maestro-1000.maestro.pasteur.fr"

how is this hostname fully qualified who sets it ? The original hostname
always seems to be this one.

I don't know, it is set before NM starts.

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:

But man says "none: NetworkManager will not manage the transient hostname
and will never set it."
Makes me wonder what exactly is the transient hostname.

It's the kernel hostname, the one used among other things in the journal.

Besides, trace for 'none' confirms hostname is "unmanaged"

So where does the short hostname I see in this case b) come from if not dhcp
(none) neither the sysconfig/network file ?

Good question. It is not NM that sets it.

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

ok. But what does exactly "set outside of NetworkManager" mean ?


No, it only takes the short hostname from DHCP.

ok, makes sens as this is what's sent


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?

Please find the 3 traces here:

http://dl.pasteur.fr/fop/P3H6bSGV/NM-hostname-mode.tar.gz

So basically, I still don't understand the 2 following cases

- none (end up with short name) : if dhcp, NM seems to still manage the
hostname despite none

In the 'none' log, the FQDN is set before NM starts. Around 14:53:41
someone adds a new connection and activates it, disconnecting the
previous DHCP connection. At the same time the kernel hostname is
changed externally to NM. I can't say who does this.


- dhcp (end up with fqdn).

In this case the short hostname got via DHCP is set by NM at
15:05:49. But later, somebody adds and activates a new connection
'xcat-enp33s0f0' with static addresses and so the DHCP hostname is
removed, restoring the initial one.

Beniamino



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