Almalinux 8.10
in a VPS …
NetworkManager 1.40.16-15.el8_9
This is very frustrarting, I am trying to change hostname for more than 2 days
This command works in all servers I have in various versions and configurations, but NOT in this one. It changes back after reboot:
I want to change myserver.tntcode.net
(default) to new.myserver.tntcode.new
hostnamectl set-hostname new.myserver.tntcode.net
reboot
My web host / ISP can change the hostname for me, and that works fine, but I want to be able to change from my end, from the command line.
After rebot I always see it chanfing int the logs /var/log/messages
Sep 16 22:45:42 new NetworkManager[630]: <info> [1726541142.2514] device (eth0): Activation: successful, device activated.
Sep 16 22:45:42 new NetworkManager[630]: <info> [1726541142.2518] manager: NetworkManager state is now CONNECTED_GLOBAL
Sep 16 22:45:42 new nm-dispatcher[670]: req:23 'up' [eth0]: new request (2 scripts)
Sep 16 22:45:42 new nm-dispatcher[670]: req:24 'connectivity-change': new request (2 scripts)
Sep 16 22:45:42 new chronyd[628]: Source 178.239.19.60 online
Sep 16 22:45:42 new chronyd[628]: Source 129.250.35.251 online
Sep 16 22:45:42 new chronyd[628]: Source 185.51.192.62 online
Sep 16 22:45:42 new chronyd[628]: Source 94.198.159.15 online
Sep 16 22:45:42 new nm-dispatcher[670]: req:23 'up' [eth0]: start running ordered scripts...
Sep 16 22:45:42 new nm-dispatcher[670]: req:24 'connectivity-change': start running ordered scripts...
Sep 16 22:45:42 new systemd-hostnamed[654]: Changed static host name to 'myserver.tntcode.net'
Sep 16 22:45:42 new NetworkManager[630]: <info> [1726541142.4532] hostname: static hostname changed from "new.myserver.tntcode.net" to "myserver.tntcode.net"
Sep 16 22:45:42 new NetworkManager[630]: <info> [1726541142.4533] audit: op="hostname-save" arg="myserver.tntcode.net" pid=1252 uid=0 result="success"
Sep 16 22:45:42 new nm-dispatcher[670]: req:25 'hostname': new request (2 scripts)
Sep 16 22:45:42 new nm-dispatcher[670]: req:25 'hostname': start running ordered scripts...
Sep 16 22:45:42 new qemu-ga[682]: info: guest-exec close [stdout cid=2] queue=0 total=0
Sep 16 22:45:42 new qemu-ga[682]: info: guest-exec close [stderr cid=3] queue=0 total=0
I understand NetworkManager changes my hostname when it connects to network, I tried setting these in /etc/NetworkManager/NetworkManager.conf
but I find the documentation very unclear regarding what goes where, if I need to add the configs under [main]
or under [connection]
or even what values to use, but I think these are related:
[main]
hostname-mode=none
hostname.from-dhcp=0
hostname.from-dns-lookup=0
hostname.only-from-default=1
Edit: when I change hostname with hostnamectl set-hostname new.myserver.tntcode.net
, without rebooting, the service NetworkManager status
mentions hostname is unmanaged
and it remains set to new hostname until I reboot.
It also keeps new hostname and hostname is unmanaged
if I restart NetworkManager service NetworkManager restart
.
Sep 16 22:58:20 myserver.tntcode.net NetworkManager[616]: <trace> [1726541900.1130] l3cfg[1238d57f0644a7d4,ifindex=2]: emit signal (platform-change, obj-type=ip6-route, change=add>
Sep 16 22:58:20 myserver.tntcode.net NetworkManager[616]: <trace> [1726541900.1130] l3cfg[1238d57f0644a7d4,ifindex=2]: emit signal (platform-change-on-idle, obj-type-flags=0x28)
Sep 16 22:58:20 myserver.tntcode.net NetworkManager[616]: <trace> [1726541900.1131] policy: set-hostname: hostname is unmanaged
Sep 16 22:58:24 myserver.tntcode.net NetworkManager[616]: <trace> [1726541904.1546] device[7f2db18f7addb8fa] (eth0): remove_pending_action (0): 'carrier-wait' not pending (expecte>
Sep 16 23:17:04 new.myserver.tntcode.net NetworkManager[616]: <info> [1726543024.9421] hostname: static hostname changed from "myserver.tntcode.net" to "new.myserver.tntcode.net"
Sep 16 23:17:04 new.myserver.tntcode.net NetworkManager[616]: <debug> [1726543024.9421] dispatcher: (25) dispatching action 'hostname'
Sep 16 23:17:04 new.myserver.tntcode.net NetworkManager[616]: <trace> [1726543024.9422] policy: set-hostname: hostname is unmanaged
Sep 16 23:17:04 new.myserver.tntcode.net NetworkManager[616]: <debug> [1726543024.9566] dispatcher: (25) succeeded (after 0.014 sec, 2 scripts invoked)
Sep 16 23:17:04 new.myserver.tntcode.net NetworkManager[616]: <debug> [1726543024.9566] dispatcher: (25) /etc/NetworkManager/dispatcher.d/20-chrony-dhcp succeeded
Sep 16 23:17:04 new.myserver.tntcode.net NetworkManager[616]: <debug> [1726543024.9567] dispatcher: (25) /etc/NetworkManager/dispatcher.d/20-chrony-onoffline succeeded