1

I am running a custom Yocto based Linux with kernel version 5.4.41. I am using systemd-network to manage my networks.

root@box:~# systemctl --version
systemd 244 (244.3+)
+PAM -AUDIT -SELINUX +IMA -APPARMOR -SMACK +SYSVINIT -UTMP -LIBCRYPTSETUP -GCRYPT -GNUTLS +ACL +XZ -LZ4 -SECCOMP +BLKID -ELFUTILS +KMOD -IDN2 -IDN -PCRE2 default-hierarchy=hybrid

I enabled systemd-networkd verbose debugging with: How to debug systemd-networkd?

I want to toggle between DHCP and Static configurations for 'eth0'. The DHCP configuration works fine. When I write my eth0.network file for the following static configuration, the file is somehow 'changed' by systemd-networkd about 3 seconds later. I cannot figure out why it is changing what I have written and I see no obvious errors.

Events:

  1. ip link set down eth0
  2. write configuration file to /etc/systemd/network/eth0.network
  3. networkctl reload
  4. networkctl reconfigure eth0

After the reconfigure command, I quickly check the file I wrote which looks like this:

[Match]
Name=eth0

[Network]
Address=192.168.1.7/24
DNS=192.168.1.1
[Route]
Gateway=192.168.1.1
Destination=0.0.0.0/0
Metric=1024

Then, several seconds later, networkd somehow re-writes the file to be this ( only when a cable is plugged in - if no cable is plugged in, the file remains as I had written it ):

[Match]
Name=eth0

[Network]
Address=192.168.1.7/24
DNS=192.168.1.7
[Route]
Gateway=192.168.1.7
Destination=192.168.1.7/0
Metric=1024

And I cannot ping Google, because the gateway is wrong. I have tried many diffenent IP Addresses.

Here is the verbose log for systemd-networkd when the file is re-written:

Jan 27 15:27:13 box systemd-networkd[9940]: rtnl: received non-static neighbor, ignoring.
Jan 27 15:27:14 box systemd-networkd[9940]: eth0: Remembering route: dst: ff00::/8, src: n/a, gw: n/a, prefsrc: n/a, scope: global, table: main, proto: boot, type: unicast
Jan 27 15:27:14 box systemd-networkd[9940]: eth0: Remembering route: dst: fe80::/64, src: n/a, gw: n/a, prefsrc: n/a, scope: global, table: main, proto: kernel, type: unicast
Jan 27 15:27:14 box systemd-networkd[9940]: eth0: Flags change: +LOWER_UP +RUNNING
Jan 27 15:27:14 box systemd-networkd[9940]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=134 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
Jan 27 15:27:14 box systemd-networkd[9940]: eth0: Gained carrier
Jan 27 15:27:14 box systemd-networkd[9940]: eth0: Setting addresses
Jan 27 15:27:14 box systemd-networkd[9940]: eth0: Remembering updated address: 192.168.1.7/24 (valid forever)
Jan 27 15:27:14 box systemd-networkd[9940]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=135 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
Jan 27 15:27:14 box systemd-networkd[9940]: eth0: Remembering route: dst: 192.168.1.7/32, src: n/a, gw: n/a, prefsrc: 192.168.1.7, scope: host, table: local, proto: kernel, type: local
Jan 27 15:27:14 box systemd-networkd[9940]: eth0: Remembering route: dst: 192.168.1.255/32, src: n/a, gw: n/a, prefsrc: 192.168.1.7, scope: link, table: local, proto: kernel, type: broadcast
Jan 27 15:27:14 box systemd-networkd[9940]: eth0: Remembering route: dst: 192.168.1.0/24, src: n/a, gw: n/a, prefsrc: 192.168.1.7, scope: link, table: main, proto: kernel, type: unicast
Jan 27 15:27:14 box systemd-networkd[9940]: eth0: Remembering route: dst: 192.168.1.0/32, src: n/a, gw: n/a, prefsrc: 192.168.1.7, scope: link, table: local, proto: kernel, type: broadcast
Jan 27 15:27:14 box systemd-networkd[9940]: eth0: Addresses set
Jan 27 15:27:14 box systemd-networkd[9940]: eth0: Configuring route: dst: n/a, src: n/a, gw: 192.168.1.1, prefsrc: n/a, scope: global, table: main, proto: static, type: unicast
Jan 27 15:27:14 box systemd-networkd[9940]: eth0: Setting routes
Jan 27 15:27:14 box systemd-networkd[9940]: eth0: Received remembered route: dst: n/a, src: n/a, gw: 192.168.1.1, prefsrc: n/a, scope: global, table: main, proto: static, type: unicast
Jan 27 15:27:14 box systemd-networkd[9940]: eth0: Routes set
Jan 27 15:27:14 box systemd-networkd[9940]: Got message type=method_call sender=:1.274 destination=org.freedesktop.network1 path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus.Properties member=Get cookie=2 reply_cookie=0 signature=ss error-name=n/a error-message=n/a
Jan 27 15:27:14 box systemd-networkd[9940]: Sent message type=method_return sender=n/a destination=:1.274 path=n/a interface=n/a member=n/a cookie=136 reply_cookie=2 signature=v error-name=n/a error-message=n/a
Jan 27 15:27:14 box systemd-networkd[9940]: Got message type=method_call sender=:1.275 destination=org.freedesktop.network1 path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus.Properties member=Get cookie=2 reply_cookie=0 signature=ss error-name=n/a error-message=n/a
Jan 27 15:27:14 box systemd-networkd[9940]: Sent message type=method_return sender=n/a destination=:1.275 path=n/a interface=n/a member=n/a cookie=137 reply_cookie=2 signature=v error-name=n/a error-message=n/a
Jan 27 15:27:15 box systemd-networkd[9940]: eth0: Remembering foreign address: fe80::691:62ff:fe40:283c/64 (valid forever)
Jan 27 15:27:15 box systemd-networkd[9940]: eth0: Gained IPv6LL
Jan 27 15:27:15 box systemd-networkd[9940]: eth0: State changed: configuring -> configured
Jan 27 15:27:15 box systemd-networkd[9940]: Sent message type=signal sender=n/a destination=n/a path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus.Properties member=PropertiesChanged cookie=138 reply_cookie=0 signature=sa{sv}as error-name=n/a error-message=n/a
Jan 27 15:27:15 box systemd-networkd[9940]: eth0: Discovering IPv6 routers
Jan 27 15:27:15 box systemd-networkd[9940]: NDISC: Started IPv6 Router Solicitation client
Jan 27 15:27:16 box systemd-networkd[9940]: eth0: Remembering route: dst: fe80::691:62ff:fe40:283c/128, src: n/a, gw: n/a, prefsrc: n/a, scope: global, table: main, proto: kernel, type: local
Jan 27 15:27:16 box systemd-networkd[9940]: Got message type=method_call sender=:1.276 destination=org.freedesktop.network1 path=/org/freedesktop/network1/link/_32 interface=org.freedesktop.DBus.Properties member=Get cookie=2 reply_cookie=0 signature=ss error-name=n/a error-message=n/a
Jan 27 15:27:16 box systemd-networkd[9940]: Sent message type=method_return sender=n/a destination=:1.276 path=n/a interface=n/a member=n/a cookie=139 reply_cookie=2 signature=v error-name=n/a error-message=n/a
Jan 27 15:27:17 box systemd-networkd[9940]: NDISC: Sent Router Solicitation, next solicitation in 4s

How can I avoid systemd-networkd re-writing my file? Thanks.

1
  • How do you know it's systemd-networkd that is rewriting your file? Commented Jan 27, 2021 at 16:56

0

You must log in to answer this question.

Browse other questions tagged .