Re: hostname-mode : short vs fqdn name
On 4/17/20 10:23 PM, Beniamino Galvani wrote: Hello Beniamino, No, I don't think it does. I think that DHCP is run before NM, probably in initrd or by other services. Indeed, in between I came to a similar conclusion. And tracing further (helping my with NM dans my initrd sources) I figured out: - the original hostname, which NM reads from dbus is indeed setup by dracut/initrd/dhclient-scripts a) when no postcsript adding a second NM manual profile is not run, results and reasons are, as expected : - hostname-mode == none : maestro-1000.maestro.pasteur.fr (original from initrd) - hostname-mode == dhcp : maestro-1000 (from dhcp) - hostname-mode == default : maestro-1000 (from dhcp) b) when postscript, which adds to the nic a higher autoconnect priority manual ip address profile is run : - hostname-mode == none : maestro-1000 (the postscript itself issues a hostname command - I missed that point initially) - hostname-mode == dhcp : maestro-1000.maestro.pasteur.fr (reset from dhcp) : I guess it's when the dhcp profile is disconnected, original hostname is reset by NM as the semantic of hostname-mode=dhcp implies) - hostname-mode == default : maestro-1000.maestro.pasteur.fr (fallback no default device) : again, semantics of hostname-mode As a matter of fact in this case I see in this trace http://dl.pasteur.fr/fop/JyY4sSwA/confignetwork-default.log.bz2 that default device setting occurs : policy: set 'xcat-enp33s0f0' (enp33s0f0) as default for IPv4 routing and DNS but *after*: policy: set-hostname: set hostname to 'maestro-1000.maestro.pasteur.fr' (no defaultdevice) I'm not really sure : is this is normal ? So, this aside everything is indeed fully explained. May I add 2 last questions though ? 1. as seen in this other trace http://dl.pasteur.fr/fop/wRQfXSQX/confignetwork-none.log.bz2 why are they many lines *long after the dhcp + static profile scenario is "finished"* we can still see many lines such as auth: call[XX]: CheckAuthorization or policy: set-hostname: hostname is unmanaged ? 2. this has nothing to do with NM and is not related to the initial thread (I just experienced it while debugging my case) but it seems that when, starting with no static hostname, we set one with hostnamectl --static set-hostname the transient hostname - is also set to that name (seems to contredict the man for --static) - *not immediatly* (I can still see for some time the original - different - transient name) Does it seem legit to you ? Thanks anyway for your help and time Best, -- TH ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: hostname-mode : short vs fqdn name
On Fri, Apr 10, 2020 at 07:44:51PM +0200, Thomas HUMMEL wrote: > On 4/9/20 10:59 AM, Beniamino Galvani wrote: > > > alking 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]: > > > [1586350409.2521] policy: get-hostname: > > > "maestro-1000.maestro.pasteur.fr" (from dbus) > > > Apr 08 14:53:29 maestro-1000.maestro.pasteur.fr NetworkManager[25235]: > > > [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. > > Hello, again > > I tried to figure out the simplier case : hostname-mode=none. > > I guess the above fqdn hostname read from D-Bus is the transient hostname, > correct ? Yes. > I don't think it can be set by dhcp if NM is the one which starts > dhclient. Correct. But I see that when NM starts, there are already dynamic addresses configured on the interface: Apr 08 14:53:28 maestro-1000.maestro.pasteur.fr NetworkManager[25235]: [1586350408.9701] platform: (enp33s0f0) signal: address 4 added: 192.168.152.2/20 lft 43173sec pref 43173sec ... and so probably DHCP was run before NM. Is this machine booting from a network share? Are you passing any network-related command line to kernel, like for example ip=... ? In such case, networking would be configured in the initrd by dracut. > As a matter of fact, I saw that dhconfig() from dhcpd-scripts > /usr/sbin/dhclient-script can indeed set the transient hostname. > The problem is that it sets the transient name only if hostname is needed, > which, looking at the script is if transient hostname is empty or localhost > : > > need_hostname () > { > CHECK_HOSTNAME=$(hostnamectl --transient) > if [[ "${CHECK_HOSTNAME}" = "(none)" ]] || >[[ "${CHECK_HOSTNAME}" = "localhost" ]] || >[[ "${CHECK_HOSTNAME}" = "localhost.localdomain" ]]; then > return 0 > else > return 1 > fi > } > > which must not be the case because of the fqdn hostname we see BEFORE NM > starts (I am assuming that dhclient is only started by NM of course here)... The dhclient-script is not run when dhclient is started by NM. > Or could that initial fqdn hostname come from systemd-hostnamed at boot > which would fall back setting the transient hostname by reverse dns lookup > of the ip address ? No, I don't think it does. I think that DHCP is run before NM, probably in initrd or by other services. Beniamino signature.asc Description: PGP signature ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: hostname-mode : short vs fqdn name
On 4/9/20 10:59 AM, Beniamino Galvani wrote: alking 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]: [1586350409.2521] policy: get-hostname: "maestro-1000.maestro.pasteur.fr" (from dbus) Apr 08 14:53:29 maestro-1000.maestro.pasteur.fr NetworkManager[25235]: [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. Hello, again I tried to figure out the simplier case : hostname-mode=none. I guess the above fqdn hostname read from D-Bus is the transient hostname, correct ? I don't think it can be set by dhcp if NM is the one which starts dhclient. As a matter of fact, I saw that dhconfig() from dhcpd-scripts /usr/sbin/dhclient-script can indeed set the transient hostname. The problem is that it sets the transient name only if hostname is needed, which, looking at the script is if transient hostname is empty or localhost : need_hostname () { CHECK_HOSTNAME=$(hostnamectl --transient) if [[ "${CHECK_HOSTNAME}" = "(none)" ]] || [[ "${CHECK_HOSTNAME}" = "localhost" ]] || [[ "${CHECK_HOSTNAME}" = "localhost.localdomain" ]]; then return 0 else return 1 fi } which must not be the case because of the fqdn hostname we see BEFORE NM starts (I am assuming that dhclient is only started by NM of course here)... Or could that initial fqdn hostname come from systemd-hostnamed at boot which would fall back setting the transient hostname by reverse dns lookup of the ip address ? thanks -- TH ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: hostname-mode : short vs fqdn name
On Thu, Apr 09, 2020 at 11:20:17AM +0200, Thomas HUMMEL wrote: > On 4/9/20 10:59 AM, Beniamino Galvani wrote: > > > > 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. > > Ok, I'll look into this but this is not related to my initial problem > indeed. > > > > In the 'none' log, the FQDN is set before NM starts > > Indeed (read from D-Bus by NM) > > > . Around 14:53:41 > > someone adds a new connection and activates it, disconnecting the > > previous DHCP connection. > > This can only be the postscript I mentionned creating the xcat- NM profile > > > At the same time the kernel hostname is > > changed externally to NM. I can't say who does this. > > Hmm this is odd. I may have missed something then. I'll look further into > it. > > > > - 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 > > The postscript. > > > and so the DHCP hostname is > > removed, restoring the initial one. > > Ok but then you mean the one set BEFORE NM starts (again, the one read from > D-Bus at the begining) you mentionned above ? Because man said for > hostname-mode == dhcp that there is no fallback (like to reverse lookup the > ip address). Correct, no fallback to reverse lookup is done. NM keeps either the last hostname set outside of NM or the one present when NM was started. > I was initially confused by this : it LOOKED LIKE even in dhcp mode, NM was > performing a reverse lookup fallback as in fact it just reset to the one it > saw initially, correct ? Right. Beniamino ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: hostname-mode : short vs fqdn name
On 4/9/20 10:59 AM, Beniamino Galvani wrote: 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. Ok, I'll look into this but this is not related to my initial problem indeed. In the 'none' log, the FQDN is set before NM starts Indeed (read from D-Bus by NM) . Around 14:53:41 someone adds a new connection and activates it, disconnecting the previous DHCP connection. This can only be the postscript I mentionned creating the xcat- NM profile At the same time the kernel hostname is changed externally to NM. I can't say who does this. Hmm this is odd. I may have missed something then. I'll look further into it. - 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 The postscript. and so the DHCP hostname is removed, restoring the initial one. Ok but then you mean the one set BEFORE NM starts (again, the one read from D-Bus at the begining) you mentionned above ? Because man said for hostname-mode == dhcp that there is no fallback (like to reverse lookup the ip address). I was initially confused by this : it LOOKED LIKE even in dhcp mode, NM was performing a reverse lookup fallback as in fact it just reset to the one it saw initially, correct ? Thanks a lot for your help. -- Thomas HUMMEL ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
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]: > [1586350409.2521] policy: get-hostname: > "maestro-1000.maestro.pasteur.fr" (from dbus) > Apr 08 14:53:29 maestro-1000.maestro.pasteur.fr NetworkManager[25235]: > [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 ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: hostname-mode : short vs fqdn name
On 4/8/20 4:18 PM, Thomas HUMMEL wrote: >> 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. 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 ? Or maybe for this case (hostname-mode=none) NM does not change the transient hostname but dhcp has initially changed it in step1 (dhcp NM profile), without NM being involed. So it is kept this way in step2 (manual profile activation) ? ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
Re: hostname-mode : short vs fqdn name
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, 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]: [1586350409.2521] policy: get-hostname: "maestro-1000.maestro.pasteur.fr" (from dbus) Apr 08 14:53:29 maestro-1000.maestro.pasteur.fr NetworkManager[25235]: [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. >> 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. 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 ? > > 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 - dhcp (end up with fqdn). Thanks for your help. -- Thomas HUMMEL ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list
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 signature.asc Description: PGP signature ___ networkmanager-list mailing list networkmanager-list@gnome.org https://mail.gnome.org/mailman/listinfo/networkmanager-list