[systemd-devel] systemd-hostnamed/hostnamectl and transient hostname change

Thomas HUMMEL thomas.hummel at pasteur.fr
Mon May 4 13:57:26 UTC 2020


On 4/30/20 10:43 AM, Zbigniew Jędrzejewski-Szmek wrote:

> Lennart opened a PR to remove the caching:
> https://github.com/systemd/systemd/pull/15624.

Great!


> The documentation is wrong. The code in hostnamed sets the kernel
> hostname when setting the static one. This was changed in
> https://github.com/systemd/systemd/commit/c779a44222:

Well, in my experience, it does indeed set the transient hostname if the 
static one is set (which indeed makes sense to me according to the 
semantics of what a static hostname should be) but not in the case when 
you set it to be the same as the current one :

hostnamectl --static set-hostname 'static' when no static hostname is 
set will set the transient as well (immediatly but with some delay for 
hostnamed to see it)

hostnamectl --static set-hostname 'newstatic' when the current static 
hostname is different thant 'newstatic' : same as above

but

hostnamectl --static set-hostname 'static' where current static hostname 
is already 'static' then transient hostname is never set.

What do you think about it ?


> (I'm assuming you're not unhappy, just
> confused by the unexpected results...). Opinions?

I may be wrong but I experienced what I think is a side effect of 
hostnamed not catching up immediatly the transient hostname change :

As a matter of fact, NetworkManager uses systemd-hostnamed as a proxy 
service to get/set the transient hostname. When this service is, for 
some reason, not available, it falls back to figuring out itself by 
calling gethostname(3).

So, depending of

- the value of hostname-mode in NetworkManager.conf(5)
- the status of systemd-hostnamed service

one, as I myself did, could experience different transient hostname 
settings.

I did try to discuss this in the networkmanager list here :

in particular starting from this post (the post above just show how much 
I was confused)

https://mail.gnome.org/archives/networkmanager-list/2020-April/msg00031.html

of this thread

https://mail.gnome.org/archives/networkmanager-list/2020-April/msg00022.html


Thanks for your help

--
Thomas HUMMEL



More information about the systemd-devel mailing list