Consistent Network Device Naming
1. Why do you need this
Servers usually have multiple network cards, either onboard integrated or inserted in PCIe slots.
The naming of the Linux system was originally in the form of eth0, eth1, but this number often does not necessarily correspond to the physical order of the NIC interface.
To solve this kind of problem, dell developed the biosdevname scheme.
In the systemd v197 version, the dell scheme has been further generalized and expanded.
The current Centos supports both dell's biosdevname and systemd's scheme.
Second, the naming strategy in Centos7
Scheme 1 : If you can get the index number of the onboard network card available from the BIOS, use this index number to name, for example: eno1, if not, try Scheme 2
Scheme 2 : If the index number of the PCI-E hot-plug slot where the network card is located can be obtained from the BIOS, use this index number to name, for example: ens1, if not, try Scheme 3
Scheme 3 : If you can get the physical location information connected to the device, use this information to name, for example: enp2s0, if not, try Scheme 5
Scheme 5 : The traditional kernel naming method, for example: eth0, the result of this naming method is unpredictable, that is, the second network card may correspond to eth0, and the first network card may correspond to eth1.
Scheme 4 uses the MAC address of the network card to name, this method is generally not used.
Three, biosdevname and net.ifnames two naming conventions
The naming convention of net.ifnames is: device type + device location + number
Equipment type:
en means Ethernet
wl means WLAN
ww means wireless wide area network WWAN
Equipment location:
eno1 onboard network card
enp0s2 pci network card
ens33 pci network card
wlp3s0 PCI wireless card
wwp0s29f7u2i2 4G modem
wlp0s2f1u4u1 Wireless network card connected to USB Hub
enx78e7d1ea46da pci network card
----------------------------------------
The naming convention for biosdevname is
Practical example:
em1 onboard network card
p3p4 pci network card
p3p4_1 virtual network card
Fourth, the actual execution order in systemd
Execute the udev rules in the following order
1./usr/lib/udev/rules.d/60-net.rules
2./usr/lib/udev/rules.d/71-biosdevname.rules
3./lib/udev/rules.d/75-net-description.rules
4./usr/lib/udev/rules.d/80-net-name-slot.rules
60-net.rules
Use the program /lib/udev/rename_device to query all files starting with ifcfg- under /etc/sysconfig/network-scripts/
If the NIC interface with HWADDR=xx:xx:xx:xx:xx:xx parameter is matched in ifcfg-xx
Then select the name set in DEVICE=yyyy as the network card name.
71-biosdevname.rules
If biosdevname is installed in the system, and the kernel parameter does not specify biosdevname=0, and the network card is not renamed in the previous step, the network card is named according to the naming convention of biosdevname, and the relevant information is obtained from the BIOS.
Mainly take type 9 (System Slot) and type 41 (Onboard Devices Extended Information) in SMBIOS
However, the version of SMBIOS is required to be higher than 2.6, and the biosdevname program must be installed in the system.
75-net-description.rules
udev fills in the following udev attribute values by checking the network card information
ID_NET_NAME_ONBOARD
ID_NET_NAME_SLOT
ID_NET_NAME_PATH
ID_NET_NAME_MAC
80-net-name-slot.rules
If the network card is not renamed in the two rules of 60-net.rules and 71-biosdevname.rules, and the kernel does not specify the net.ifnames=0 parameter
Then udev tries to name the NIC with the following property values in turn, if none of these property values are present, the NIC will not be renamed.
ID_NET_NAME_ONBOARD
ID_NET_NAME_SLOT
ID_NET_NAME_PATH
71-biosdevname.rules above is the policy that actually implements biosdevname
75-net-description.rules and 80-net-name-slot.rules actually implement Scheme 1,2,3
According to the above process, it can be seen that the name of the network card is affected by the two kernel parameters biosdevname and net.ifnames.
Both parameters can be provided in the grub configuration.
biosdevname=0 is the system default (dell server default is 1), net.ifnames=1 is the system default:
#vi /boot/grub/grub.conf
kernel /boot/vmlinuz biosdevname=1
initrd /boot/initrd.img
The strategy order of Scheme mentioned in Section 2 is the default of the system.
If the system BIOS meets the requirements, and biosdevname is installed in the system, and biosdevname=1 is enabled, then biosdevname takes precedence;
If the BIOS does not meet the biosdevname requirements or biosdevname=0, the rules of systemd still take precedence.
If the user defines a udev rule to modify the kernel device name, the user rule takes precedence.
When the kernel parameters are used in combination, the results are as follows:
Default kernel parameters (biosdevname=0, net.ifnames=1): NIC name "enp5s2"
biosdevname=1, net.ifnames=0: NIC name "em1"
biosdevname=0, net.ifnames=0: network card name "eth0" (the most traditional way, eth0 eth1 foolishly indistinguishable)
Reference documentation:
http://benjr.tw/93340
https://docs.google.com/viewer?url=http://domsch.com/linux/lpc2010/lpc2010-network-device-naming.pdf
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Networking_Guide/
http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/
http://blog.chinaunix.net/uid-14735472-id-4195429.html