Network interface name: Difference between revisions
(Created page with "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 == <code>eth0</code>, <code>eth1</code>, etc were simply assigned by the kernel. There are many possible way to use this scheme, * . reboot with the kernel parameter <code>net.ifnames=0</code>, or made persistent by editing <code>/etc/default/grub</code> and running <code>update-grub</code> * ove...") |
|||
Line 20: | Line 20: | ||
== Predictable names scheme == | == Predictable names scheme == | ||
[https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/ Predictable Network Interface naming] and is part of systemd, to which Ubuntu has been transitioning as of version 15.04. the idea is to set interface name depends on physical location of hardware and can be predicted/guessed by looking at <code>lspci</code> or <code>lshw</code> output. | |||
There are 3 ways how interface name is assigned, [https://major.io/2015/08/21/understanding-systemds-predictable-network-device-names/ Refer here for more] | |||
# based on [[BIOS]]/Firmware for onboard cards | |||
# based on PCI information | |||
# based on MAC address of the interface | |||
== Custome names scheme<ref>https://wiki.debian.org/NetworkInterfaceNames#custom</ref> == | == Custome names scheme<ref>https://wiki.debian.org/NetworkInterfaceNames#custom</ref> == |
Revision as of 14:05, 27 May 2023
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
Predictable Network Interface naming and is part of systemd, to which Ubuntu has been transitioning as of version 15.04. the idea is to set interface name depends on physical location of hardware and can be predicted/guessed by looking at lspci
or lshw
output.
There are 3 ways how interface name is assigned, Refer here for more
- based on BIOS/Firmware for onboard cards
- based on PCI information
- based on MAC address of the interface
Custome names scheme[1]
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