I have an embedded target where the hostname is expected to be a string derived in part from the MAC address of an Ethernet interface. I've been looking at how to properly set the system's hostname and also have systemd-networkd use it in the DHCP request it sends out, however there seems to be an order of operations issue.
1. in systemd/core/main.c the /etc/hostname contents are unconditionally read 2. I can add a service that uses the special network-pre.target to override /etc/hostname with my generated string and I see that while the initial string is pickedup by systemd, the new hostname will in fact be used 3. I then have a .network file specifying DHCP on that Ethernet interface But then on initial boot I see that the DHCP Discover coming out has option 12 set to the original hostname that systemd picked up in main.c, even though the network-pre.target caused my unit to run. I can then reboot the system and this time main.c picks up the "new" hostname and option 12 is indeed set to this. One workaround I found was to have my unit write the Hostname= option to the .network file but that seems like the wrong approach. Is there a correct way to replace or otherwise set the hostname and have systemd use it from the beginning and ensure that the DHCP client specifies it in option 12? Thanks, -Andrey _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel