Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Naming rules for network cards in later versions of Centos7

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

I. equipment naming standard

Reference:

Chapter 8 of the official documentation: https://access.redhat.com/documentation/zh-cn/red_hat_enterprise_linux/7/html/networking_guide/ch-consistent_network_device_naming#sec-Naming_Schemes_Hierarchy

Some of the information refer to the blog post: thank you!

Noway11: https://www.cnblogs.com/zyd112/p/8143464.html

Wang Weijie: https://www.jianshu.com/p/b66981dbb389

The previous version of Centos7's Centost system adopted the traditional command standard for network card commands, such as eth0,eth2. Individuals understand that eth identifies the link layer encapsulation type of the network card, and the following number is the network card number, but this number is not immutable. If the server adds or deletes new hardware, it may change, which brings some trouble to the operation and maintenance work. In order to solve this problem, a new network device naming convention has been introduced in later versions of Centos7: consistent Network device naming (CONSISTENT NETWORK DEVICE NAMING), and Centos7 will support both biosdevname and net.ifnames naming conventions.

1.net.ifnames naming convention is: device type + device location + port number

Device type: en stands for Ethernet, wl for Wireless Local area Network (WLAN), and ww for Wireless wide area Network (WWAN).

Device location: the device index number of the integrated device, or the bus slot number of the expansion card

Port number: index number of the onboard integrated device or physical port number on the expansion card

Device name Typ

Format description eno1 onboard device index number ens33 hot-swappable slot index number

For example:

Name device type description eno1 onboard network card onboard 1 network card enp0s2pci network card PCI expansion card port 2 ens33pci network card hot-swappable slot 3 PCI-E slot 3 port wlp3s0PCI wireless network card port 3 PCI expansion card port 0

2.biosdevname naming convention

The Centos system needs to install the biosdevname package to use the biosdevname naming convention. The biosdevname program reads the type 9 (system slot) and type 41 (on-board device extension information) field information in the BIOS information to name the network card. (version of SMBIOS is required to be higher than 2.6)

Device old name new name example on-board built-in network card eth [0123 …] Em [1234...] Em1PCI expansion card network interface eth [0123 …] P [slot number] p [port number] p3p4 subinterface virtual function eth [0123 …] P [slot number] p [port number] _ [subinterface number] p3p4_1

Second, the default network card naming rules of the system

The naming rules of official documents are described as follows:

By default, systemd uses the following strategy to name the interface in a supported naming scheme:

Option 1: if the firmware or BIOS information is applicable and available, use the name of the firmware or BIOS that integrates the index number for the onboard device (for example: eno1), otherwise use option 2. (for onboard integrated Nic naming)

Option 2: if the firmware or BIOS information is applicable and available, use the firmware or BIOS name that integrates providing the index number for the PCI quick-swappable slot (for example, ens1), otherwise use option 3. (for PCI-E extended network card pin naming standard)

Scenario 3: if the physical location information of the hardware connector is available, use a name that integrates that information (for example: enp2s0), otherwise use scenario 5.

Scenario 4: the name of the MAC address of the consolidated interface is not used by default (for example: enx78e7d1ea46da), but the user can choose to use this scheme. (name the network card according to the MAC address)

Option 5: the traditional unpredictable kernel naming scheme is used when other methods fail (e.g. eth0) (traditional command rules are used when none of the above command information can be obtained)

This policy (as described above) is the default policy. This scenario is used if biosdevname is enabled on the system. Note: enabling biosdevname requires adding biosdevname=1 as a command line argument (except for the Dell system), which will be used by default as long as you install biosdevname. If the user has added udev rules, which will have a higher kernel device name, these rules will take precedence

III. Equipment renaming strategy

The official document on device renaming is described as follows:

The rules in the 1./usr/lib/udev/rules.d/60-net.rules file let the udev help tool / lib/udev/rename_device view all / etc/sysconfig/network-scripts/ifcfg-suffix files. If the ifcfg file containing the HWADDR entry is found to match the MAC address of an interface, it renames the interface to the name given by the DEVICE directive in the ifcfg file.

The rules in 2./usr/lib/udev/rules.d/71-biosdevname.rules tell biosdevname to rename the interface according to its naming strategy, that is, the interface was not renamed in the previous step, biosdevname is installed, and biosdevname=0 is given as a kernel command on the boot command line.

The rules in 3./lib/udev/rules.d/75-net-description.rules let udev fill in the internal udev device attribute values ID_NET_NAME_ONBOARD, ID_NET_NAME_SLOT, ID_NET_NAME_PATH by checking the network interface device. Note: some device properties may be in an undefined state.

The rules in 4./usr/lib/udev/rules.d/80-net-name-slot.rules tell udev to rename the interface in the following priority order: ID_NET_NAME_ONBOARD, ID_NET_NAME_SLOT, ID_NET_NAME_PATH. It also provides the following information: the interface was not renamed in step 1 or 2, and the kernel parameter net.ifnames=0 is not given. If one parameter is not set, the next one is set in the order of the list. If no parameters are set, the interface is not renamed.

From the official point of view, 1 and 4 are all related to the naming rules of the system systemd udev, and 2 are related to biosdevname. I personally understand that the uses of the four files are as follows:

1./usr/lib/udev/rules.d/60-net.rules (the rename_device program is named based on a custom configuration file)

If there is a file in the directory / etc/sysconfig/network-scripts/ that starts with ifcfg- and contains the MAC of the specified network card, it is named after the DEVICE field in the ifcfg file.

2./usr/lib/udev/rules.d/71-biosdevname.rules (biosdevname is automatically named based on BIOS information)

If the corresponding configuration is not found in the file at the beginning of ifcfg, then the Nic is named according to the biosdevname naming standard to see if the system has the biosdevname package installed and the system does not have the device parameter biosdevname=0.

3./lib/udev/rules.d/75-net-description.rules (systemd-udev is named based on systemd-udev and Nic information)

If neither of the two rules is hit, check the network card information and name it based on the field specified by the network card information.

4./usr/lib/udev/rules.d/80-net-name-slot.rules (systemd-udev is named based on systemd-udev based on BIOS information)

If the Nic information does not have a specified field, it will be named according to the on-board slot information obtained by BIOS.

Summary: the priority of custom configuration, followed by biosdevname, and finally systemd-udev automatic configuration.

Restore the traditional naming standard of the network card

Judging from the above naming strategy and naming rules, the Nic should be named by the two parameters biosdevname and net.ifnames. The official also gives the default values of the two parameters: iosdevname=0 is the system default value (dell server default is 1), and net.ifnames=1 is the system default value.

If you want to restore the previous traditional naming convention, you only need to set two parameters to 0 in the grub file, as follows:

1. Edit the / etc/sysconfig/grub file and add net.ifnames=0 biosdevname=0 at the end of the GRUB_CMDLINE_LINUX field

two。 To regenerate the configuration file grub configuration file, perform the following naming

Grub2-mkconfig-o / boot/grub2/grub.cfg

3. Manually edit the file at the beginning of ifcf- in the / etc/sysconfig/network-scripts/ directory. Note: the HWADDR field should correspond to the MAC address of the network card to be named, or the UUID field should correspond to the UUID of the network card.

4. Restart the system.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report