You are not logged in.

#1 2022-10-26 16:36:11

tunaja
Member
Registered: 2020-03-03
Posts: 3

[SOLVED]Network interface file naming question

Greetings all.

I was working on changing some things with my network configuration, and I started to wonder about the naming convention for the files in the /etc/systemd/network/ directory. My network configuration is in a file named 10-eno1.network. However, I saw in the systemd-networkd topic under "Wired Adapter using DHCP" that the example used a file named 20-wired.network.

Can anyone explain or provide a link that explains why some config files have 10-en*.network and why some have 20-wired.network? Or what the number prefixes mean?

I've checked through the wiki, internet searches, and two linux admin books, and can't find anything that explains this.

Thanks.

Last edited by tunaja (2022-10-27 16:06:19)

Offline

#2 2022-10-26 16:42:01

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 24,462

Re: [SOLVED]Network interface file naming question

man pages are your friend. And see the first sentence of https://wiki.archlinux.org/title/System … n_examples

https://www.freedesktop.org/software/sy … twork.html

Description wrote:

...
The .network files are read from the files located in the system network directories /usr/lib/systemd/network and /usr/local/lib/systemd/network, the volatile runtime network directory /run/systemd/network and the local administration network directory /etc/systemd/network. All configuration files are collectively sorted and processed in alphanumeric order, regardless of the directories in which they live. However, files with identical filenames replace each other. It is recommended that each filename is prefixed with a number (e.g. 10-eth0.network). Otherwise, the default .network files or those generated by systemd-network-generator.service(8) may take precedence over user configured files. Files in /etc/ have the highest priority, files in /run/ take precedence over files with the same name under /usr/. This can be used to override a system-supplied configuration file with a local file if needed. As a special case, an empty file (file size 0) or symlink with the same name pointing to /dev/null disables the configuration file entirely (it is "masked").

Along with the network file foo.network, a "drop-in" directory foo.network.d/ may exist. All files with the suffix ".conf" from this directory will be merged in the alphanumeric order and parsed after the main file itself has been parsed. This is useful to alter or add configuration settings, without having to modify the main configuration file. Each drop-in file must have appropriate section headers.

In addition to /etc/systemd/network, drop-in ".d" directories can be placed in /usr/lib/systemd/network or /run/systemd/network directories. Drop-in files in /etc/ take precedence over those in /run/ which in turn take precedence over those in /usr/lib/. Drop-in files under any of these directories take precedence over the main network file wherever located.

Also visible under

man systemd.networkd

Last edited by V1del (2022-10-26 16:43:13)

Offline

#3 2022-10-26 17:30:00

tunaja
Member
Registered: 2020-03-03
Posts: 3

Re: [SOLVED]Network interface file naming question

Thanks for replying.

I saw those links, and I saw about prefixing them with numbers. I want to the difference between using 10-eno1.network and 20-wired.network when they could have the same configuration data except [Match] having the full interface name in the 20-wired.network file.

I understand the alphabetical and lexical orders, but if I only have one ethernet adapter on my PC, is one better than the other when in operation?

Last edited by tunaja (2022-10-26 17:30:26)

Offline

#4 2022-10-26 17:37:12

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 24,462

Re: [SOLVED]Network interface file naming question

There is no difference, this is for you as a human to know which file is which at a glance.

Many "directory" config files operate this way, modprobe.d, alpm-hooks, modules-load.d .... The only thing the tools care about is that there's no direct name collision and a relevant suffix e.g. .conf/.network or so in place. how you are going to name and structure them is for your personal benefit when looking at the list of files.

As for multiple Match directives see

The link wrote:

The network file contains a [Match] section, which determines if a given network file may be applied to a given interface; and a [Network] section specifying how the interface should be configured. The first (in alphanumeric order) of the network files that matches a given interface is applied, all later files are ignored, even if they match as well.

Last edited by V1del (2022-10-26 17:44:12)

Offline

#5 2022-10-27 16:03:44

tunaja
Member
Registered: 2020-03-03
Posts: 3

Re: [SOLVED]Network interface file naming question

Okay thanks. I appreciate the help.

Offline

Board footer

Powered by FluxBB