How to set the hostname assigned by DHCP server?

I have been fighting with this and I am ready to punch this machine. :slight_smile:

I have a client which obtains an IP via DHCP. This of course works without issue. However, I can not make this machine keep the machine name as it is assigned via DHCP. I have found networkd, hostnamed, and NetworkManager all capable of setting the hostname and I think they do… it just ends up with whatever is in /etc/hostname.
I have tried setting the name to localhost in the /etc/hostname which should be overwritten by the DHCP name.
I have modified NetworkManager.conf only to see “warnings” in systemctl that the change to the DHCP name was blocked due to “systemd security” and I should use sethostname or hostnamectl (I don’t recall which for sure, atm).

Anyone have clues as to what I need to change? Accepting the hostname assigned by DHCP should be the default… but it is not or it does not function properly or one of the other systemd services is resetting it. Sure wish we still lived in the day of, do one thing and to do it well.

Did you set up a static hostname in /etc/hostname ? It should be empty if you want to use the Transient hostname or containing localhost . If possible remove the /etc/hostname file, without network the fallback hostname is used and it is hardcoded in systemd. NM and systemd-netweorkd will only update the Transient hostname with the value receiving from the DHCP server. The static hostname will not be touched.

By default systemd/hostnamectl will ignore the Transient hostname if a valid static hostname in /etc/hostname is found. If the static hostname is localhost the Transient hostname is used. But again the /etc/hostname file will not be touched. The problems are programs that read form /etc/hostname . But for example journalctl will pick up the Transient hostname.

For example (with systemd-networkd, DHCP provided Hostname arch)

With /etc/hostname containing localhost

$ hostnamectl 
   Static hostname: localhost
   Transient hostname: arch
   Icon name: computer-vm
   ...

With /etc/hostname removed

$ hostnamectl 
   Static hostname: n/a
   Transient hostname: arch
   Icon name: computer-vm
   ...

with a hostname on /etc/hostname

$ hostnamectl 
   Static hostname: arch-static
   Icon name: computer-vm

Please post the real log entry.

I will edit this post as I work through there various configuration changes:

First, no static hostname assigned:

$ rm /etc/hostname && reboot

$ hostnamectl
   Static hostname: n/a
Transient hostname: archlinux
         Icon name: computer
        Machine ID: 01a83b30426646bc8fd3d018ee8f81ed
           Boot ID: f4246185eaba41f7bdf31b9325386e45
  Operating System: Manjaro ARM
            Kernel: Linux 5.9.1-1-MANJARO-ARM
      Architecture: arm64

I have also tried an empty /etc/hostname file and a /etc/hostname file with localhost

If I then modify /etc/NetworkManager/NetworkManager.conf:

 $ cat /etc/NetworkManager/NetworkManager.conf
 $ Configuration file for NetworkManager.
 $ See "man 5 NetworkManager.conf" for details.
 [main]
 hostname-mode=dhcp

And then restart NetworkManager and check the status:

[root@archlinux ~]# systemctl status NetworkManager
● NetworkManager.service - Network Manager
 Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/NetworkManager.service.d
         └─NetworkManager-ovs.conf
 Active: active (running) since Wed 2020-11-04 14:14:50 CST; 11s ago
   Docs: man:NetworkManager(8)
Main PID: 1354 (NetworkManager)
  Tasks: 5 (limit: 3711)
  CGroup: /system.slice/NetworkManager.service
         ├─1354 /usr/bin/NetworkManager --no-daemon
         └─1366 /usr/bin/dhclient -d -q -sf /usr/lib/nm-dhcp-helper -pf /var/run/NetworkManager/dhclient-eth0.pid -lf /var/lib/NetworkManager/dhcl>

Nov 04 14:14:51 archlinux NetworkManager[1354]: <info>  [1604520891.4582] device (eth0): state change: secondaries -> activated (reason 'none', sys-if>
Nov 04 14:14:51 archlinux NetworkManager[1354]: <info>  [1604520891.4604] manager: NetworkManager state is now CONNECTED_LOCAL
Nov 04 14:14:51 archlinux NetworkManager[1354]: <info>  [1604520891.4636] manager: NetworkManager state is now CONNECTED_SITE
Nov 04 14:14:51 archlinux NetworkManager[1354]: <info>  [1604520891.4643] policy: set 'Wired connection 1' (eth0) as default for IPv4 routing and DNS
Nov 04 14:14:51 archlinux NetworkManager[1354]: <info>  [1604520891.4654] policy: set-hostname: set hostname to 'rpi' (from DHCPv4)
Nov 04 14:14:51 rpi dhclient[1366]: bound to 10.208.101.110 -- renewal in 39339 seconds.
Nov 04 14:14:51 rpi NetworkManager[1354]: <info>  [1604520891.4967] device (eth0): Activation: successful, device activated.
Nov 04 14:14:51 rpi NetworkManager[1354]: <info>  [1604520891.4992] manager: startup complete
Nov 04 14:14:51 rpi NetworkManager[1354]: <info>  [1604520891.5270] agent-manager: agent[c483dfddf3d657e3,:1.39/org.freedesktop.nm-applet/0]: agent re>
Nov 04 14:14:51 rpi NetworkManager[1354]: <info>  [1604520891.6313] manager: NetworkManager state is now CONNECTED_GLOBAL

And you see it did successfully set the name to “rpi” which is indeed the dhcpd assigned name. So at this point I thought I had it… but…

Now reboot…

$ systemctl status NetworkManager
● NetworkManager.service - Network Manager
 Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/NetworkManager.service.d
         └─NetworkManager-ovs.conf
 Active: active (running) since Wed 2020-11-04 14:25:43 CST; 1min 40s ago
   Docs: man:NetworkManager(8)
Main PID: 304 (NetworkManager)
  Tasks: 4 (limit: 3711)
 CGroup: /system.slice/NetworkManager.service
         ├─304 /usr/bin/NetworkManager --no-daemon
         └─440 /usr/bin/dhclient -d -q -sf /usr/lib/nm-dhcp-helper -pf /var/run/NetworkManager/dhclient-eth0.pid -lf /var/lib/NetworkManager/dhclient-40b69cbf-6567-3931->

Nov 04 14:26:11 archlinux NetworkManager[304]: <warn>  [1604521571.4502] policy: set-hostname: couldn't set the system hostname to 'rpi': (1) Operation not permitted
Nov 04 14:26:11 archlinux NetworkManager[304]: <warn>  [1604521571.4503] policy: set-hostname: you should use hostnamed when systemd hardening is in effect!
Nov 04 14:26:11 archlinux NetworkManager[304]: <info>  [1604521571.5047] device (eth0): Activation: successful, device activated.
Nov 04 14:26:11 archlinux NetworkManager[304]: <info>  [1604521571.5283] manager: startup complete
Nov 04 14:26:36 archlinux NetworkManager[304]: <info>  [1604521596.4789] manager: NetworkManager state is now CONNECTED_GLOBAL
Nov 04 14:26:36 archlinux NetworkManager[304]: <info>  [1604521596.4819] policy: set-hostname: current hostname was changed outside NetworkManager: 'archlinux'
Nov 04 14:26:36 archlinux NetworkManager[304]: <info>  [1604521596.4821] policy: set-hostname: set hostname to 'rpi' (from DHCPv4)
Nov 04 14:26:36 archlinux NetworkManager[304]: <warn>  [1604521596.4821] policy: set-hostname: couldn't set the system hostname to 'rpi': (1) Operation not permitted
Nov 04 14:26:36 archlinux NetworkManager[304]: <warn>  [1604521596.4822] policy: set-hostname: you should use hostnamed when systemd hardening is in effect!
Nov 04 14:26:59 archlinux NetworkManager[304]: <info>  [1604521619.1293] agent-manager: agent[524c7fb20f762782,:1.38/org.freedesktop.nm-applet/0]: agent registered

$ hostnamectl
Static hostname: n/a
Transient hostname: archlinux
     Icon name: computer
    Machine ID: 01a83b30426646bc8fd3d018ee8f81ed
       Boot ID: 9c5ceb1c5a1b422d9d098b0243fc4861
Operating System: Manjaro ARM
        Kernel: Linux 5.9.1-1-MANJARO-ARM
  Architecture: arm64

So on reboot, systemd security kicks in… I did not even know this existed.

$ systemd-analyze security
NetworkManager.service                    7.8 EXPOSED   🙁 
   --- cut ---

But as you can see from log of the reboot… something changes the name to archlinux outside of NetworkManager.

I have even tried masking systemd.hostnamed thinking it was dynamically changing it, but that does not resolve the issue. Usually the fight is to stop a system from accepting the DHCP assigned name… as it is usually the default. So I am fairly stumped at the moment.

(I am finished making edits of this post and await any assistance.)

Please check the complete journal, specially the first try to set up the hostname and the first error.

Also double check if no other dhcp client is running on this machine. Manjaro Arm has a long history of staring multiple dhcp client at boot.

I tried it with now with Manjaro XFCE on real Hardware (x86-64) and NM, and it worked with the default settings (no need form hostname-mode=dhcp )

Thank you for your time and efforts. But I will need to pick this up again tomorrow. Maybe the answer will come to me in my sleep. :slight_smile:

I do not see multiple dhcp clients being launched on boot but I do see several starts of systemd.hostnamed and dbus-org.freedesktop.hostname1.service being launched. So I think there are 4 processes at play here: dbus, NetworkManager, networkd and dhcpcd. And there is the NetworkManager “Policy”, whatever that is.

This is a problem. networkd and dhcpcd can start its own dhcp clients. Also they might try to set up Network contentions. If you want use NetworkManager make sure that networkd and dhcpcd are disabled and in case of dhcpcd better remove it.

You are already using NetworkManager with dhclient which works often but is also not a default. NM has its own dhcp-client build in. But sometimes the build in dhcp-client follows to rules to strictly, resulting in no connection.

Agreed, it does appear there are multiple processes messing with the hostname. I’ll start there in the morning.

What’s the drop-in for?

This is not from the actual machine but a very similar one, I expect them to be the same. This is not my handy work but part of the Manjaro RPi image. I assume it is just a helper file to keep the startup order correct if one is using openvswitch. However, I am not.

$ cat NetworkManager-ovs.conf 
[Unit]
After=openvswitch.service

You have a good eye though, I did not notice it.

If you’re not using it…drop it.

sudo systemctl revert NetworkManager.service

Then, just to be sure:

sudo systemctl disable --now openvswitch.service

Then restart NM.

I am pretty sure the openvswitch file does not factor into this issue. I am however confident the issue with NetworkManager and its policies or something that can confine/alter those policies. As you can see below, NetworkManager attempts to set the hostname correctly but is blocked by policy. Either its own policy or some other policy set by polkit-1.

I have tried modifying a couple of the relevant files in /usr/share/polkit-1/actions but no success yet. I am still hunting around for the correct file to modify.

[root@archlinux ~]# journalctl -xe | grep 302
Nov 05 07:50:15 archlinux NetworkManager[302]: <info>  [1604584215.8327] NetworkManager (version 1.26.4-1) is starting... (for the first time)
Nov 05 07:50:15 archlinux NetworkManager[302]: <info>  [1604584215.8329] Read config: /etc/NetworkManager/NetworkManager.conf (lib: 20-connectivity.conf) (etc: dhcp-client.conf, disable-random-mac.conf)
Nov 05 07:50:15 archlinux NetworkManager[302]: <info>  [1604584215.8616] bus-manager: acquired D-Bus service "org.freedesktop.NetworkManager"
Nov 05 07:50:15 archlinux NetworkManager[302]: <info>  [1604584215.9417] manager[0xaaaacbfb9030]: monitoring kernel firmware directory '/lib/firmware'.
Nov 05 07:50:15 archlinux dbus-daemon[295]: [system] Activating via systemd: service name='org.freedesktop.hostname1' unit='dbus-org.freedesktop.hostname1.service' requested by ':1.3' (uid=0 pid=302 comm="/usr/bin/NetworkManager --no-daemon ")
Nov 05 07:50:40 archlinux NetworkManager[302]: <info>  [1604584240.9903] hostname: hostname: hostnamed not used as proxy creation failed with: Error calling StartServiceByName for org.freedesktop.hostname1: Timeout was reached
Nov 05 07:50:40 archlinux NetworkManager[302]: <info>  [1604584240.9929] dns-mgr[0xaaaacbf73220]: init: dns=default,systemd-resolved rc-manager=symlink
Nov 05 07:50:40 archlinux NetworkManager[302]: <info>  [1604584240.9944] manager[0xaaaacbfb9030]: rfkill: Wi-Fi hardware radio set enabled
Nov 05 07:50:40 archlinux NetworkManager[302]: <info>  [1604584240.9945] manager[0xaaaacbfb9030]: rfkill: WWAN hardware radio set enabled
Nov 05 07:50:41 archlinux NetworkManager[302]: <info>  [1604584241.0758] Loaded device plugin: NMTeamFactory (/usr/lib/NetworkManager/1.26.4-1/libnm-device-plugin-team.so)
Nov 05 07:50:41 archlinux NetworkManager[302]: <info>  [1604584241.1149] Loaded device plugin: NMBluezManager (/usr/lib/NetworkManager/1.26.4-1/libnm-device-plugin-bluetooth.so)
Nov 05 07:50:41 archlinux NetworkManager[302]: <info>  [1604584241.1181] Loaded device plugin: NMWwanFactory (/usr/lib/NetworkManager/1.26.4-1/libnm-device-plugin-wwan.so)
Nov 05 07:50:41 archlinux NetworkManager[302]: <info>  [1604584241.1261] Loaded device plugin: NMWifiFactory (/usr/lib/NetworkManager/1.26.4-1/libnm-device-plugin-wifi.so)
Nov 05 07:50:41 archlinux NetworkManager[302]: <info>  [1604584241.1306] Loaded device plugin: NMOvsFactory (/usr/lib/NetworkManager/1.26.4-1/libnm-device-plugin-ovs.so)
Nov 05 07:50:41 archlinux NetworkManager[302]: <info>  [1604584241.1338] Loaded device plugin: NMAtmManager (/usr/lib/NetworkManager/1.26.4-1/libnm-device-plugin-adsl.so)
Nov 05 07:50:41 archlinux NetworkManager[302]: <info>  [1604584241.1358] manager: rfkill: Wi-Fi enabled by radio killswitch; enabled by state file
Nov 05 07:50:41 archlinux NetworkManager[302]: <info>  [1604584241.1364] manager: rfkill: WWAN enabled by radio killswitch; enabled by state file
Nov 05 07:50:41 archlinux NetworkManager[302]: <info>  [1604584241.1369] manager: Networking is enabled by state file
Nov 05 07:50:41 archlinux NetworkManager[302]: <info>  [1604584241.1377] dhcp-init: Using DHCP client 'dhclient'
Nov 05 07:50:41 archlinux dbus-daemon[295]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' requested by ':1.3' (uid=0 pid=302 comm="/usr/bin/NetworkManager --no-daemon ")
Nov 05 07:50:41 archlinux NetworkManager[302]: <info>  [1604584241.1391] settings: Loaded settings plugin: keyfile (internal)
Nov 05 07:50:41 archlinux NetworkManager[302]: <info>  [1604584241.1588] device (lo): carrier: link connected
Nov 05 07:50:41 archlinux NetworkManager[302]: <info>  [1604584241.1599] manager: (lo): new Generic device (/org/freedesktop/NetworkManager/Devices/1)
Nov 05 07:50:41 archlinux NetworkManager[302]: <info>  [1604584241.1641] manager: (eth0): new Ethernet device (/org/freedesktop/NetworkManager/Devices/2)
Nov 05 07:50:41 archlinux NetworkManager[302]: <info>  [1604584241.1679] device (eth0): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
Nov 05 07:50:41 archlinux NetworkManager[302]: <info>  [1604584241.1955] ovsdb: Could not connect: No such file or directory
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.1997] device (eth0): carrier: link connected
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.2006] device (eth0): state change: unavailable -> disconnected (reason 'carrier-changed', sys-iface-state: 'managed')
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.2034] policy: auto-activating connection 'Wired connection 1' (40b69cbf-6567-3931-a8a8-a1c0dae4dbed)
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.2051] device (eth0): Activation: starting connection 'Wired connection 1' (40b69cbf-6567-3931-a8a8-a1c0dae4dbed)
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.2054] device (eth0): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'managed')
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.2064] manager: NetworkManager state is now CONNECTING
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.2069] device (eth0): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.2083] device (eth0): state change: config -> ip-config (reason 'none', sys-iface-state: 'managed')
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.2112] dhcp4 (eth0): activation: beginning transaction (timeout in 45 seconds)
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.2300] dhcp4 (eth0): dhclient started with pid 442
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3983] dhcp4 (eth0):   address 10.208.101.110
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3984] dhcp4 (eth0):   plen 24 (255.255.255.0)
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3984] dhcp4 (eth0):   gateway 10.208.101.254
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3984] dhcp4 (eth0):   lease time 86400
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3985] dhcp4 (eth0):   hostname 'rpi'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3985] dhcp4 (eth0):   nameserver '10.208.3.113'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3985] dhcp4 (eth0):   nameserver '10.208.3.214'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3985] dhcp4 (eth0):   domain name 'XXXX.com'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3986] dhcp4 (eth0): option broadcast_address    => '10.208.101.255'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3986] dhcp4 (eth0): option dad_wait_time        => '0'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3986] dhcp4 (eth0): option dhcp_lease_time      => '86400'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3986] dhcp4 (eth0): option dhcp_message_type    => '5'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3987] dhcp4 (eth0): option dhcp_server_identifier => '10.208.3.43'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3987] dhcp4 (eth0): option domain_name          => 'XXXX.com'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3987] dhcp4 (eth0): option domain_name_servers  => '10.208.3.113 10.208.3.214'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3987] dhcp4 (eth0): option expiry               => '1604670643'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3988] dhcp4 (eth0): option host_name            => 'rpi'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3988] dhcp4 (eth0): option ip_address           => '10.208.101.110'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3988] dhcp4 (eth0): option network_number       => '10.208.101.0'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3988] dhcp4 (eth0): option next_server          => '0.0.0.0'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3989] dhcp4 (eth0): option requested_broadcast_address => '1'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3989] dhcp4 (eth0): option requested_domain_name => '1'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3989] dhcp4 (eth0): option requested_domain_name_servers => '1'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3989] dhcp4 (eth0): option requested_host_name  => '1'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3990] dhcp4 (eth0): option requested_ms_classless_static_routes => '1'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3990] dhcp4 (eth0): option requested_ntp_servers => '1'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3990] dhcp4 (eth0): option requested_rfc3442_classless_static_routes => '1'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3990] dhcp4 (eth0): option requested_root_path  => '1'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3990] dhcp4 (eth0): option requested_routers    => '1'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3991] dhcp4 (eth0): option requested_static_routes => '1'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3991] dhcp4 (eth0): option requested_subnet_mask => '1'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3991] dhcp4 (eth0): option requested_time_offset => '1'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3991] dhcp4 (eth0): option requested_wpad       => '1'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3991] dhcp4 (eth0): option routers              => '10.208.101.254'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3992] dhcp4 (eth0): option subnet_mask          => '255.255.255.0'
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.3992] dhcp4 (eth0): state changed unknown -> extended
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.4042] device (eth0): state change: ip-config -> ip-check (reason 'none', sys-iface-state: 'managed')
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.4219] device (eth0): state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'managed')
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.4226] device (eth0): state change: secondaries -> activated (reason 'none', sys-iface-state: 'managed')
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.4238] manager: NetworkManager state is now CONNECTED_LOCAL
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.4271] manager: NetworkManager state is now CONNECTED_SITE
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.4275] policy: set 'Wired connection 1' (eth0) as default for IPv4 routing and DNS
Nov 05 07:50:43 archlinux NetworkManager[302]: <info>  [1604584243.4279] policy: set-hostname: set hostname to 'rpi' (from DHCPv4)
Nov 05 07:50:43 archlinux NetworkManager[302]: <warn>  [1604584243.4280] policy: set-hostname: couldn't set the system hostname to 'rpi': (1) Operation not permitted
Nov 05 07:50:43 archlinux NetworkManager[302]: <warn>  [1604584243.4280] policy: set-hostname: you should use hostnamed when systemd hardening is in effect!
Nov 05 07:50:43 archlinux dbus-daemon[295]: [system] Activating via systemd: service name='org.freedesktop.resolve1' unit='dbus-org.freedesktop.resolve1.service' requested by ':1.3' (uid=0 pid=302 comm="/usr/bin/NetworkManager --no-daemon ")
Nov 05 07:51:04 archlinux NetworkManager[302]: <info>  [1604584264.5369] device (eth0): Activation: successful, device activated.
Nov 05 07:51:04 archlinux NetworkManager[302]: <info>  [1604584264.5585] manager: startup complete
Nov 05 07:51:04 archlinux NetworkManager[302]: <info>  [1604584264.9613] manager: NetworkManager state is now CONNECTED_GLOBAL
Nov 05 07:51:04 archlinux NetworkManager[302]: <info>  [1604584264.9634] policy: set-hostname: current hostname was changed outside NetworkManager: 'archlinux'
Nov 05 07:51:04 archlinux NetworkManager[302]: <info>  [1604584264.9635] policy: set-hostname: set hostname to 'rpi' (from DHCPv4)
Nov 05 07:51:04 archlinux NetworkManager[302]: <warn>  [1604584264.9636] policy: set-hostname: couldn't set the system hostname to 'rpi': (1) Operation not permitted
Nov 05 07:51:04 archlinux NetworkManager[302]: <warn>  [1604584264.9636] policy: set-hostname: you should use hostnamed when systemd hardening is in effect!
Nov 05 07:51:26 archlinux NetworkManager[302]: <info>  [1604584286.0491] agent-manager: agent[0e4f25bf891ba981,:1.37/org.freedesktop.nm-applet/0]: agent registered

I also think this has nothing to do with it.

Since this seems to be a problem in Manjaro ARM, which Device and which image do you use?

I tried it today with a “Raspberry Pi 3 Model B” and “Manjaro-ARM-xfce-rpi4-20.10” image. I used the “First Time setup” via SSH, after reboot did an update and removed the hostname file. After another reboot NM set up the “Transient hostname” without any problems. Even with systemd-networkd
enabled but not configured.

NM log
$ journalctl -b -u NetworkManager --no-pager
-- Logs begin at Sat 2020-10-03 20:13:07 CEST, end at Thu 2020-11-05 15:16:48 CET. --
Nov 05 15:01:31 archlinux systemd[1]: Starting Network Manager...
Nov 05 15:01:32 archlinux NetworkManager[272]: <info>  [1604584892.1108] NetworkManager (version 1.26.4-1) is starting... (for the first time)
Nov 05 15:01:32 archlinux NetworkManager[272]: <info>  [1604584892.1111] Read config: /etc/NetworkManager/NetworkManager.conf (lib: 20-connectivity.conf) (etc: dhcp-client.conf, disable-random-mac.conf)
Nov 05 15:01:32 archlinux systemd[1]: Started Network Manager.
Nov 05 15:01:32 archlinux NetworkManager[272]: <info>  [1604584892.1393] bus-manager: acquired D-Bus service "org.freedesktop.NetworkManager"
Nov 05 15:01:32 archlinux NetworkManager[272]: <info>  [1604584892.2459] manager[0xaaaaba32e030]: monitoring kernel firmware directory '/lib/firmware'.
Nov 05 15:01:32 archlinux NetworkManager[272]: <info>  [1604584892.9565] hostname: hostname: using hostnamed
Nov 05 15:01:32 archlinux NetworkManager[272]: <info>  [1604584892.9590] dns-mgr[0xaaaaba300220]: init: dns=default,systemd-resolved rc-manager=symlink
Nov 05 15:01:32 archlinux NetworkManager[272]: <info>  [1604584892.9649] rfkill0: found Wi-Fi radio killswitch (at /sys/devices/platform/soc/3f300000.mmcnr/mmc_host/mmc1/mmc1:0001/mmc1:0001:1/ieee80211/phy0/rfkill0) (driver brcmfmac)
Nov 05 15:01:32 archlinux NetworkManager[272]: <info>  [1604584892.9660] manager[0xaaaaba32e030]: rfkill: Wi-Fi hardware radio set enabled
Nov 05 15:01:32 archlinux NetworkManager[272]: <info>  [1604584892.9661] manager[0xaaaaba32e030]: rfkill: WWAN hardware radio set enabled
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.2102] Loaded device plugin: NMTeamFactory (/usr/lib/NetworkManager/1.26.4-1/libnm-device-plugin-team.so)
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.3347] Loaded device plugin: NMBluezManager (/usr/lib/NetworkManager/1.26.4-1/libnm-device-plugin-bluetooth.so)
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.3504] Loaded device plugin: NMWwanFactory (/usr/lib/NetworkManager/1.26.4-1/libnm-device-plugin-wwan.so)
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.3903] Loaded device plugin: NMWifiFactory (/usr/lib/NetworkManager/1.26.4-1/libnm-device-plugin-wifi.so)
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.4259] Loaded device plugin: NMOvsFactory (/usr/lib/NetworkManager/1.26.4-1/libnm-device-plugin-ovs.so)
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.4657] Loaded device plugin: NMAtmManager (/usr/lib/NetworkManager/1.26.4-1/libnm-device-plugin-adsl.so)
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.4682] manager: rfkill: Wi-Fi enabled by radio killswitch; enabled by state file
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.4691] manager: rfkill: WWAN enabled by radio killswitch; enabled by state file
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.4698] manager: Networking is enabled by state file
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.4819] dhcp-init: Using DHCP client 'dhclient'
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.5208] settings: Loaded settings plugin: keyfile (internal)
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.5877] device (lo): carrier: link connected
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.5899] manager: (lo): new Generic device (/org/freedesktop/NetworkManager/Devices/1)
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.5974] device (wlan0): driver supports Access Point (AP) mode
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.6020] manager: (wlan0): new 802.11 Wi-Fi device (/org/freedesktop/NetworkManager/Devices/2)
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.6083] device (wlan0): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.6789] manager: (eth0): new Ethernet device (/org/freedesktop/NetworkManager/Devices/3)
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.8135] ovsdb: Could not connect: No such file or directory
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.8253] device (eth0): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.8953] device (eth0): carrier: link connected
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.9378] settings: (eth0): created default wired connection 'Wired connection 1'
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.9521] device (eth0): state change: unavailable -> disconnected (reason 'none', sys-iface-state: 'managed')
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.9572] policy: auto-activating connection 'Wired connection 1' (6dc6c80f-a9a3-3c61-9143-fa788096771a)
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.9617] device (eth0): Activation: starting connection 'Wired connection 1' (6dc6c80f-a9a3-3c61-9143-fa788096771a)
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.9627] device (eth0): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'managed')
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.9650] manager: NetworkManager state is now CONNECTING
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.9663] device (eth0): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.9706] device (eth0): state change: config -> ip-config (reason 'none', sys-iface-state: 'managed')
Nov 05 15:01:33 archlinux NetworkManager[272]: <info>  [1604584893.9833] dhcp4 (eth0): activation: beginning transaction (timeout in 45 seconds)
Nov 05 15:01:34 archlinux NetworkManager[272]: <info>  [1604584894.0554] dhcp4 (eth0): dhclient started with pid 346
Nov 05 15:01:34 archlinux dhclient[346]: DHCPREQUEST for 172.17.17.3 on eth0 to 255.255.255.255 port 67
Nov 05 15:01:34 archlinux NetworkManager[272]: <info>  [1604584894.5103] device (wlan0): supplicant interface state: internal-starting -> disconnected
Nov 05 15:01:34 archlinux NetworkManager[272]: <info>  [1604584894.5108] Wi-Fi P2P device controlled by interface wlan0 created
Nov 05 15:01:34 archlinux NetworkManager[272]: <info>  [1604584894.5124] manager: (p2p-dev-wlan0): new 802.11 Wi-Fi P2P device (/org/freedesktop/NetworkManager/Devices/4)
Nov 05 15:01:34 archlinux NetworkManager[272]: <info>  [1604584894.5143] device (p2p-dev-wlan0): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
Nov 05 15:01:34 archlinux NetworkManager[272]: <info>  [1604584894.5190] device (wlan0): state change: unavailable -> disconnected (reason 'supplicant-available', sys-iface-state: 'managed')
Nov 05 15:01:34 archlinux NetworkManager[272]: <info>  [1604584894.5242] device (p2p-dev-wlan0): state change: unavailable -> disconnected (reason 'none', sys-iface-state: 'managed')
Nov 05 15:01:34 archlinux NetworkManager[272]: <warn>  [1604584894.5259] sup-iface[615b8c6504704848,0,wlan0]: call-p2p-cancel: failed with P2P cancel failed
Nov 05 15:01:35 archlinux NetworkManager[272]: <warn>  [1604584895.9406] ndisc[0xaaaaba3ea0f0,"eth0"]: failure sending router solicitation: No buffer space available (105)
Nov 05 15:01:36 archlinux NetworkManager[272]: <info>  [1604584896.2569] device (eth0): carrier: link connected
Nov 05 15:01:42 archlinux dhclient[346]: DHCPREQUEST for 172.17.17.3 on eth0 to 255.255.255.255 port 67
Nov 05 15:01:42 archlinux dhclient[346]: DHCPACK of 172.17.17.3 from 172.17.17.1
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6454] dhcp4 (eth0):   address 172.17.17.3
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6456] dhcp4 (eth0):   plen 24 (255.255.255.0)
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6456] dhcp4 (eth0):   gateway 172.17.17.1
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6457] dhcp4 (eth0):   lease time 43200
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6458] dhcp4 (eth0):   hostname 'test-dyn'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6458] dhcp4 (eth0):   nameserver '172.17.17.1'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6458] dhcp4 (eth0):   domain name 'lan'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6459] dhcp4 (eth0): option broadcast_address    => '172.17.17.255'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6460] dhcp4 (eth0): option dad_wait_time        => '0'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6460] dhcp4 (eth0): option dhcp_lease_time      => '43200'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6461] dhcp4 (eth0): option dhcp_message_type    => '5'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6461] dhcp4 (eth0): option dhcp_rebinding_time  => '37800'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6461] dhcp4 (eth0): option dhcp_renewal_time    => '21600'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6462] dhcp4 (eth0): option dhcp_server_identifier => '172.17.17.1'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6462] dhcp4 (eth0): option domain_name          => 'lan'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6462] dhcp4 (eth0): option domain_name_servers  => '172.17.17.1'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6463] dhcp4 (eth0): option expiry               => '1604628102'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6463] dhcp4 (eth0): option host_name            => 'test-dyn'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6464] dhcp4 (eth0): option ip_address           => '172.17.17.3'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6464] dhcp4 (eth0): option network_number       => '172.17.17.0'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6464] dhcp4 (eth0): option next_server          => '172.17.17.1'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6465] dhcp4 (eth0): option requested_broadcast_address => '1'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6465] dhcp4 (eth0): option requested_domain_name => '1'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6465] dhcp4 (eth0): option requested_domain_name_servers => '1'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6466] dhcp4 (eth0): option requested_host_name  => '1'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6466] dhcp4 (eth0): option requested_ms_classless_static_routes => '1'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6467] dhcp4 (eth0): option requested_ntp_servers => '1'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6467] dhcp4 (eth0): option requested_rfc3442_classless_static_routes => '1'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6468] dhcp4 (eth0): option requested_root_path  => '1'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6468] dhcp4 (eth0): option requested_routers    => '1'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6468] dhcp4 (eth0): option requested_static_routes => '1'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6469] dhcp4 (eth0): option requested_subnet_mask => '1'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6469] dhcp4 (eth0): option requested_time_offset => '1'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6469] dhcp4 (eth0): option requested_wpad       => '1'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6470] dhcp4 (eth0): option routers              => '172.17.17.1'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6470] dhcp4 (eth0): option subnet_mask          => '255.255.255.0'
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6471] dhcp4 (eth0): state changed unknown -> extended
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6529] device (eth0): state change: ip-config -> ip-check (reason 'none', sys-iface-state: 'managed')
Nov 05 15:01:42 archlinux dhclient[346]: bound to 172.17.17.3 -- renewal in 19284 seconds.
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6700] device (eth0): state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'managed')
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6713] device (eth0): state change: secondaries -> activated (reason 'none', sys-iface-state: 'managed')
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6742] manager: NetworkManager state is now CONNECTED_LOCAL
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6811] manager: NetworkManager state is now CONNECTED_SITE
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6820] policy: set 'Wired connection 1' (eth0) as default for IPv4 routing and DNS
Nov 05 15:01:42 archlinux NetworkManager[272]: <info>  [1604584902.6833] policy: set-hostname: set hostname to 'test-dyn' (from DHCPv4)
Nov 05 15:01:42 test-dyn NetworkManager[272]: <info>  [1604584902.7085] device (eth0): Activation: successful, device activated.
Nov 05 15:01:42 test-dyn NetworkManager[272]: <info>  [1604584902.7166] manager: startup complete
Nov 05 15:01:42 test-dyn NetworkManager[272]: <info>  [1604584902.8682] manager: NetworkManager state is now CONNECTED_GLOBAL

Now, that is interesting… hmm. Guess it is time to backup to the beginning and start again. This build did start with the 20.8 image… I’ll try with a clean 20.10 image.

It seems the 20.10 image works as expected. In checking the /etc/NetworkManager directory, I do not see the policy files that my previous image has. Now I am wondering if this is related to my installation of sssd, as it has a reason to protect the hostname from changes. I’ll move forward with my configuration on this image while keeping an eye on that directory and how sssd might effect things.

If it turns out that sssd is the cause, it will be rather ironic, as it is the use of sssd that I need the hostname to change via dhcpd.