You are not logged in.
Hi, I am new to archlinux and on my Debian- systems my network adapters always got eth0 as identifier.
I want to keep this and there are two ways of to specify the names: udev and systemd. Now which is best practice?
To realize it with systemd I can create the file "/etc/systemd/network/00-eth0.link" and insert the following code:
[Match]
MACAddress=xx:xx:xx:xx:xx:xx
[Link]
Name=eth0
udev would be something like the file "/etc/udev/rules.d/76-netnames.rules"
SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="xx:xx:xx:xx:xx:xx", NAME="eth0"
And, if systemd is the preferred way, where can I put the file? At the moment I create the file in the directory "/etc/systemd/network". Is there another, better location and how do I enable them afterwards. I'm talking about something similar to "systemctl enable ..."
Thanks in advance!
Last edited by schrotti12 (2018-01-12 12:46:55)
Offline
systemd actually uses udev rules to name network devices, check /usr/lib/udev/rules.d/80-net-setup-link.rules .
See https://wiki.archlinux.org/index.php/Ne … evice_name for details
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline
This always seemed easiest to me:
ln -s /dev/null /etc/systemd/network/99-default.link
Or just add ther kernel parameter
net.ifnames=0
Although these don't give predictable names. Predictable names are the default behavior of systemd. If you want to *disable* predictable names in favor of old-style naming, then these will work.
Last edited by Trilby (2018-01-12 13:13:12)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Online
Hey, thanks for the answers. I tried udev with the file
/etc/udev/rules.d/10-network.rules
and content
SUBSYSTEM=="net", ACTION=="add", ADDR{address}=="xx:xx:xx:xx:xx:xx", NAME=="eth0"
The mac address is correct, but the adapter does not get "eth0".
When I try it with systemd, it works.
I don't want to disable the mechanism. I just want to know what is best practice and keep using it this way.
I can live with systemd. Is it okay, if I put the .link files in "/etc/systemd/network" or should I put it somewhere else and symlink it there?
Thanks again!
Last edited by schrotti12 (2018-01-12 14:49:40)
Offline
I tried udev with the file
/etc/udev/rules.d/10-network.rules
and content
SUBSYSTEM=="net", ACTION=="add", ADDR{address}=="xx:xx:xx:xx:xx:xx", NAME=="eth0"
That entry will not match it is using ADDR{address} instead of ATTR{address} as per the wiki example.
Offline
I doubt there's a BestPractice for this, but looking at usecases can help to find one.
Everything i can find indicates that /etc/systemd/network folder is used exclusively by systemd-networkd .
If you use anything else to manage network configuration, the /etc/systemd/network method fails.
The udev rules are applied before network configuration managers are started and should work with everything, including systemd-networkd .
Even if your system were to boot with another init system, your network names from udev rules are likely to stay the same.
summary :
A Does systemd-networkd cover all your current network management needs ?
B. Will systemd-networkd be able to satisfy your network management needs in the forseeable future ?
If both A and B are true, using the systemd method is a reasonable choice.
In all other cases the udev method is better.
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline
I don't want to disable the mechanism. I just want to know what is best practice and keep using it...
That doesn't really add up. The mechanism you don't want to disable is precisely what renames your interface from eth0 to something potentially like enp0s32 or whatever it might be. If you want to keep the kernel name of eth0, then disabling the renaming is precisely what you should do. Don't try to double up the renaming.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Online
Okay, thank you all. That helped a lot. I think, I will stick to udev because it is more generic and works with other systems.
@Lone_Wolf: Thanks for the hint with ADDR/ATTR: Typical typo, I have to work more carefully. And also thank you for the detailed explanation.
@Trilby: I want to stick to the new systems. Even Debian, the most conservative system I know, switches to the new rules. To sum it up: I want to use the new systems, but configure them to name the interfaces "eth[...]". Thanks a lot!
Offline
Lone_Wolf: Thanks for the hint with ADDR/ATTR: And also thank you for the detailed explanation.
The ADDR/ATTR thingy was mentioned by loqs, not by me.
Please add [Solved] to the title (edit the first post)
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline