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:
- What is the difference between
system network directory
andlocal administration network directory
? - Why the container gets automatically networks settings from
/usr/lib/systemd/network/
directory?
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?The way I read this, you might need to full stop the network management to make a new configuration file take affect.
Try:
Then see if the new files you created in
/etc/systemd
have started to be active.