Network interface name
The Linux kernel assigns names to network interfaces, nowaday there are multiple network interface naming scheme is available and each has pros and cons.
Simple scheme
eth0
, eth1
, etc were simply assigned by the kernel.
There are many possible way to use this scheme,
- . reboot with the kernel parameter
net.ifnames=0
, or made persistent by editing/etc/default/grub
and runningupdate-grub
- override
/lib/systemd/network/99-default.link
, with a custom version in/etc/systemd/network/
, or similarly override/lib/udev/rules.d/80-net-setup-link.rules
, or mask the latter by using a/dev/null
symlink instead of a custom version, or...
Persistent names scheme
udev
to identify interfaces by MAC address and assign a fixed interface number to any interface by writing the rules to /etc/udev/rules.d/xxx.rules
for example,
#/etc/udev/rules.d/70-persistent-net.rules
# PCI device 0x8086:0x100e (e1000e)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="aa:bb:cc:dd:ee:ff", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
Predictable names scheme
Red Hat Enterprise Linux uses predictable network interface names. These names are stable across reboots and network adapter replacements[1]
Custome names scheme[2]
Using systemd.link
#/etc/systemd/network/10-persistent-net.link
[Match]
MACAddress=01:23:45:67:89:ab
[Link]
Name=lan0
To verify the new policies to work after a reboot,
- run
udev control --reload
(or/etc/init.d/udev force-reload
, orservice udev force-reload
) - then
- for hotplug NICs, disconnect and reconnect them (or unload/reload the driver; if your SSH session doesn't go through this NIC...)
- for non-hotplug NICs, run
udevadm trigger
, then check the logs (your SSH connection should still be okay even if your.link
file was rejected as nonsense), then restart networking.
It is also possible to reorganize the naming policy by overriding /lib/systemd/network/99-default.link
, for instance to insist that all network interfaces are named purely by MAC address:
#/etc/systemd/network/99-default.link
[Match]
OriginalName=*
[Link]
NamePolicy=mac
MACAddressPolicy=persistent