Hello,
I hope I'm not on the wrong list to ask this. On CentOS 8.1
x86_64/systemd-239-18.el8_1.4.x86_64 I'm experiencing the following:
Starting with no static hostname and a transient hostname set by
dracut/initrd (this is a PXE booted stateless osimage and
'hostname-mode' is set to 'none' in NetworkManager.conf) :
[root@maestro-1000 ~]# cat /proc/sys/kernel/hostname
maestro-1000
[root@maestro-1000 ~]# dbus-send --print-reply --system
--dest=org.freedesktop.hostname1 /org/freedesktop/hostname1
org.freedesktop.DBus.Properties.Get string:'org.freedesktop.hostname1'
string:'Hostname'
method return time=1587394362.680900 sender=:1.73 -> destination=:1.72
serial=3 reply_serial=2
variant string "maestro-1000"
[root@maestro-1000 ~]# dbus-send --print-reply --system
--dest=org.freedesktop.hostname1 /org/freedesktop/hostname1
org.freedesktop.DBus.Properties.Get string:'org.freedesktop.hostname1'
string:'StaticHostname'
method return time=1587394371.482559 sender=:1.73 -> destination=:1.74
serial=5 reply_serial=2
variant string ""
[root@maestro-1000 ~]# cat /etc/hostname
cat: /etc/hostname: No such file or directory
[root@maestro-1000 ~]# hostnamectl status
Static hostname: n/a
Transient hostname: maestro-1000
Icon name: computer-server
Chassis: server
Machine ID: d1996816500e4d5ca3fe8b20af23cec1
Boot ID: 4cc11d011b35465fa9a2ce2737719e78
Operating System: CentOS Linux 8 (Core)
CPE OS Name: cpe:/o:centos:centos:8
Kernel: Linux 4.18.0-147.5.1.el8_1.x86_64
Architecture: x86-64
I setup a static hostname with hostnamectl(1) command using only the
--static flag:
# hostnamectl --static set-hostname toto
[root@maestro-1000 ~]# cat /proc/sys/kernel/hostname
toto
As expected a /etc/hostname file is created:
[root@maestro-1000 ~]# cat /proc/sys/kernel/hostname
toto
and the change is visible on dbus or via hostnamectl
[root@maestro-1000 ~]# dbus-send --print-reply --system
--dest=org.freedesktop.hostname1 /org/freedesktop/hostname1
org.freedesktop.DBus.Properties.Get string:'org.freedesktop.hostname1'
string:'StaticHostname'
method return time=1587394555.550333 sender=:1.80 -> destination=:1.83
serial=8 reply_serial=2
variant string "toto"
[root@maestro-1000 ~]# hostnamectl status
Static hostname: toto
Transient hostname: maestro-1000
Icon name: computer-server
Chassis: server
Machine ID: d1996816500e4d5ca3fe8b20af23cec1
Boot ID: 4cc11d011b35465fa9a2ce2737719e78
Operating System: CentOS Linux 8 (Core)
CPE OS Name: cpe:/o:centos:centos:8
Kernel: Linux 4.18.0-147.5.1.el8_1.x86_64
Architecture: x86-64
At this point, the transient hostname is unchanged (which is what I'd
expect) as seen with hostnamectl above or directly asking dbus:
[root@maestro-1000 ~]# dbus-send --print-reply --system
--dest=org.freedesktop.hostname1 /org/freedesktop/hostname1
org.freedesktop.DBus.Properties.Get string:'org.freedesktop.hostname1'
string:'Hostname'
method return time=1587394568.997699 sender=:1.80 -> destination=:1.85
serial=9 reply_serial=2
variant string "maestro-1000"
but a moment later, it get sets to 'toto':
[root@maestro-1000 ~]# dbus-send --print-reply --system
--dest=org.freedesktop.hostname1 /org/freedesktop/hostname1
org.freedesktop.DBus.Properties.Get string:'org.freedesktop.hostname1'
string:'Hostname'
method return time=1587394788.123612 sender=:1.99 -> destination=:1.98
serial=3 reply_serial=2
variant string "toto"
So my questions are
1. why does the transient hostname change while I stated --static only
while running hostnamectl ?
2. why does the change take some time to appear on dbus ?
3. what is supposed to happen the other way around ? i.e. if I change
the transient hostname (hostname(1) command or writing to
/proc/sys/kernel/hostname) : is dbus/hostnamectl supposed to see the
change ? When and how ?
Note : as a Centos 8.1 standard install I've got of course the
systemd-hostnamed service "enabled" (actually static) but I did not ran
it myself and NetworkManager (hostname-mode=none) does not manage the
transient hostname. It only uses this service as a proxy to get the
'original' hostname.
Thanks for your help
--
Thomas HUMMEL
_______________________________________________
systemd-devel mailing list
systemd-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/systemd-devel