0

I started experimenting systemd-networkd on both host machine and systemd-nspawn containers. After having disabled all other network management services like NetworkManager, on host machine I created .network files under

/etc/systemd/network

and everything worked fine. In systemd-nspawn containers instead, the system ignored the .network file I inserted in

/etc/systemd/network/

even if I correctly matched network adapter name (host0) in [Match] .network file section. Later by using

# networkctl status host0

I have found out that such interface was taking the configuration from

/usr/lib/systemd/network/80-container-host0.network

file. I inserted in it the correct networking settings and everything worked fine.

From man systemd-networkd:

The configuration files are read from the files located in the system network directory /usr/lib/systemd/network, the volatile runtime network directory  /run/systemd/network and the local administration network directory /etc/systemd/network.

Questions:

  1. What is the difference between system network directory and local administration network directory?
  2. Why the container gets automatically networks settings from /usr/lib/systemd/network/ directory?

1 Answer 1

2

The "system network directory" is where packages should install files.

The "local administration directory" is where human administrators are expected to add and edit custom files.

You report putting a file in the "/etc/systemd" directory, but having a parallel file in "/usr/lib/systemd" seemingly override it.

The files in "/etc/systemd" are supposed to take precedence in the event of a conflict. Did you notice this other part of the systemd-networkd man page?

Network configurations applied before networkd is started are not removed, and static configuration applied by networkd is not removed when networkd exits. Dynamic configuration applied by networkd may also optionally be left in place on shutdown. This ensures restarting networkd does not cut the network connection, and, in particular, that it is safe to transition between the initrd and the real root, and back.

The way I read this, you might need to full stop the network management to make a new configuration file take affect.

Try:

sudo systemctl stop systemd-networkd
sudo systemctl start systemd-networkd

Then see if the new files you created in /etc/systemd have started to be active.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .