systemd-networkd: What is the configuration file precedence

I have a system I need to configure via systemd-networkd. For configuring the ethernet adapter eth0 I created a file /etc/systemd/network/eth.network with the following contents:

[Match]
Name=eth*
KernelCommandLine=!nfsroot

[Network]
Address=10.0.1.100/24
Gateway=10.0.1.1
DNS=8.8.8.8

Unfortunately, after setting the logging output to verbose, I found that systemd-networkd actually reads its config from /lib/systemd/network/80-wired.network which configures DHCP for that adapter instead.

My question: Is it safe to delete/move that file? Why does it override my file? (I was under the impression, that /etc holds precedence over files that shipped with systemd.)

EDIT: I am using a modification of the poky reference distribution of the yocto project.


All files from the corresponding directories in /etc, /run, and /usr/lib are collected into a single list.

The precedence is per-file – if two files in /etc and /usr have the same name, then the file in /etc takes priority while the one in /usr is ignored. (The rest of /usr isn't ignored, only that one file is.) This applies to most systemd-related configuration.

Afterwards, in case of match-oriented files such as .network files, the entire list is sorted by file name in ASCII order, and the first matching file wins. It doesn't matter which directory the file came from – if it's at the top of the list it wins.

In ASCII, all numbers (0x30–0x39) will sort before any letters (0x40–0x7f). Meaning, 8* goes before e*.

This is why the included file is named 80-something – it leaves place for your custom files to be named 27-whatever or 50-whatever.