Este contenido no está disponible en el idioma seleccionado.
Chapter 1. Implementing consistent network interface naming
The udev device manager implements consistent device naming in Red Hat Enterprise Linux. The device manager supports different naming schemes and, by default, assigns fixed names based on firmware, topology, and location information.
Without consistent device naming, the Linux kernel assigns names to network interfaces by combining a fixed prefix and an index. The index increases as the kernel initializes the network devices. For example, eth0 represents the first Ethernet device being probed on start-up. If you add another network interface controller to the system, the assignment of the kernel device names is no longer fixed because, after a reboot, the devices can initialize in a different order. In that case, the kernel can name the devices differently.
To solve this problem, udev assigns consistent device names. This has the following advantages:
- Device names are stable across reboots.
- Device names stay fixed even if you add or remove hardware.
- Defective hardware can be seamlessly replaced.
- The network naming is stateless and does not require explicit configuration files.
Generally, Red Hat does not support systems where consistent device naming is disabled. For exceptions, see the Red Hat Knowledgebase solution Is it safe to set net.ifnames=0.
1.1. How the udev device manager renames network interfaces Copiar enlaceEnlace copiado en el portapapeles!
The udev device manager processes a set of rules to implement a consistent naming scheme for network interfaces.
Order of rule files:
Optional:
/usr/lib/udev/rules.d/60-net.rulesThis file exists only if you install the
initscripts-rename-devicepackage. The/usr/lib/udev/rules.d/60-net.rulesfile defines that the deprecated/usr/lib/udev/rename_devicehelper utility searches for theHWADDRparameter in/etc/sysconfig/network-scripts/ifcfg-*files. If the value set in the variable matches the MAC address of an interface, the helper utility renames the interface to the name set in theDEVICEparameter of theifcfgfile.If the system uses only NetworkManager connection profiles in keyfile format,
udevskips this step.Only on Dell systems:
/usr/lib/udev/rules.d/71-biosdevname.rulesThis file exists only if the
biosdevnamepackage is installed, and the rules file defines that thebiosdevnameutility renames the interface according to its naming policy, if it was not renamed in the previous step.NoteInstall and use
biosdevnameonly on Dell systems./usr/lib/udev/rules.d/75-net-description.rulesThis file defines how
udevexamines the network interface and sets the properties inudev-internal variables. These variables are then processed in the next step by the/usr/lib/udev/rules.d/80-net-setup-link.rulesfile. Some of the properties can be undefined./usr/lib/udev/rules.d/80-net-setup-link.rulesThis file calls the
net_setup_linkbuiltin of theudevservice, andudevrenames the interface based on the order of the policies in theNamePolicyparameter in the/usr/lib/systemd/network/99-default.linkfile. For further details, see Network interface naming policies.If none of the policies applies,
udevdoes not rename the interface.
1.2. Network interface naming policies Copiar enlaceEnlace copiado en el portapapeles!
By default, the udev device manager uses the /usr/lib/systemd/network/99-default.link file to determine how it renames interfaces. The NamePolicy parameter in this file defines which naming policies udev applies and in what order.
Default order:
NamePolicy=keep kernel database onboard slot path
NamePolicy=keep kernel database onboard slot path
The following table describes the different actions of udev based on which policy matches first as specified by the NamePolicy parameter:
| Policy | Description | Example name |
|---|---|---|
| keep |
If the device already has a name that was assigned in the user space, | |
| kernel |
If the kernel indicates that a device name is predictable, |
|
| database |
This policy assigns names based on mappings in the |
|
| onboard | Device names incorporate firmware or BIOS-provided index numbers for onboard devices. |
|
| slot | Device names incorporate firmware or BIOS-provided PCI Express (PCIe) hot-plug slot-index numbers. |
|
| path | Device names incorporate the physical location of the connector of the hardware. |
|
| mac | Device names incorporate the MAC address. By default, Red Hat Enterprise Linux does not use this policy, but administrators can enable it. |
|
1.3. Network interface naming schemes Copiar enlaceEnlace copiado en el portapapeles!
The udev device manager uses certain stable interface attributes that device drivers provide to generate consistent device names.
If a new udev version changes how the service creates names for certain interfaces, Red Hat adds a new scheme version and documents the details in the systemd.net-naming-scheme(7) man page on your system. By default, Red Hat Enterprise Linux (RHEL) 9 uses the rhel-9.0 naming scheme, even if you install or update to a later minor version of RHEL.
To prevent new drivers from providing more or other attributes for a network interface, the rhel-net-naming-sysattrs package provides the /usr/lib/udev/hwdb.d/50-net-naming-sysattr-allowlist.hwdb database. This database defines which sysfs values the udev service can use to create network interface names. The entries in the database are also versioned and influenced by the scheme version.
On RHEL 9.4 and later, you can also use all rhel-8.* naming schemes.
If you want to use a scheme other than the default, you can switch the network interface naming scheme.
For further details about the naming schemes for different device types and platforms, see the systemd.net-naming-scheme(7) man page on your system.
1.4. Switching to a different network interface naming scheme Copiar enlaceEnlace copiado en el portapapeles!
By default, (RHEL) uses the rhel-9.0 naming scheme, even if you install or update to a later minor version of RHEL. While the default naming scheme fits in most scenarios, there might be reasons to switch to a different scheme version.
Examples when you must change the naming scheme:
- A new scheme can help to better identify a device if it adds additional attributes, such as a slot number, to an interface name.
-
An new scheme can prevent
udevfrom falling back to the kernel-assigned device names (eth*). This happens if the driver does not provide enough unique attributes for two or more interfaces to generate unique names for them.
Prerequisites
- You have access to the console of the server.
Procedure
List the network interfaces:
ip link show
# ip link show 2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:00:5e:00:53:1a brd ff:ff:ff:ff:ff:ff ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow Record the MAC addresses of the interfaces.
Optional: Display the
ID_NET_NAMING_SCHEMEproperty of a network interface to identify the naming scheme that RHEL currently uses:udevadm info --query=property --property=ID_NET_NAMING_SCHEME /sys/class/net/eno1
# udevadm info --query=property --property=ID_NET_NAMING_SCHEME /sys/class/net/eno1 ID_NET_NAMING_SCHEME=rhel-9.0Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note that the property is not available on the
loloopback device.Append the
net.naming-scheme=<scheme>option to the command line of all installed kernels, for example:grubby --update-kernel=ALL --args=net.naming-scheme=rhel-9.4
# grubby --update-kernel=ALL --args=net.naming-scheme=rhel-9.4Copy to Clipboard Copied! Toggle word wrap Toggle overflow Reboot the system.
reboot
# rebootCopy to Clipboard Copied! Toggle word wrap Toggle overflow Based on the MAC addresses you recorded, identify the new names of network interfaces that have changed due to the different naming scheme:
ip link show
# ip link show 2: eno1np0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:00:5e:00:53:1a brd ff:ff:ff:ff:ff:ff ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow After switching the scheme,
udevnames the device with the specified MAC addresseno1np0, whereas it was namedeno1before.Identify which NetworkManager connection profile uses an interface with the previous name:
nmcli -f device,name connection show
# nmcli -f device,name connection show DEVICE NAME eno1 example_profile ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
connection.interface-nameproperty in the connection profile to the new interface name:nmcli connection modify example_profile connection.interface-name "eno1np0"
# nmcli connection modify example_profile connection.interface-name "eno1np0"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Reactivate the connection profile:
nmcli connection up example_profile
# nmcli connection up example_profileCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Identify the naming scheme that RHEL now uses by displaying the
ID_NET_NAMING_SCHEMEproperty of a network interface:udevadm info --query=property --property=ID_NET_NAMING_SCHEME /sys/class/net/eno1np0
# udevadm info --query=property --property=ID_NET_NAMING_SCHEME /sys/class/net/eno1np0 ID_NET_NAMING_SCHEME=_rhel-9.4Copy to Clipboard Copied! Toggle word wrap Toggle overflow
1.5. Customizing the prefix for Ethernet interfaces during installation Copiar enlaceEnlace copiado en el portapapeles!
If you do not want to use the default device-naming policy for Ethernet interfaces, you can set a custom device prefix during the Red Hat Enterprise Linux (RHEL) installation.
Red Hat supports systems with customized Ethernet prefixes only if you set the prefix during the RHEL installation. Using the prefixdevname utility on already deployed systems is not supported.
If you set a device prefix during the installation, the udev service uses the <prefix><index> format for Ethernet interfaces after the installation. For example, if you set the prefix net, the service assigns the names net0, net1, and so on to the Ethernet interfaces.
The udev service appends the index to the custom prefix, and preserves the index values of known Ethernet interfaces. If you add an interface, udev assigns an index value that is one greater than the previously-assigned index value to the new interface.
Prerequisites
- The prefix consists of ASCII characters.
- The prefix is an alphanumeric string.
- The prefix is shorter than 16 characters.
-
The prefix does not conflict with any other well-known network interface prefix, such as
eth,eno,ens, andem.
Procedure
- Boot the Red Hat Enterprise Linux installation media.
In the boot manager, follow these steps:
-
Select the
Install Red Hat Enterprise Linux <version>entry. - Press Tab to edit the entry.
-
Append
net.ifnames.prefix=<prefix>to the kernel options. - Press Enter to start the installation program.
-
Select the
- Install Red Hat Enterprise Linux.
Verification
To verify the interface names, display the network interfaces:
ip link show
# ip link show ... 2: net0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:00:5e:00:53:1a brd ff:ff:ff:ff:ff:ff ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow
1.6. Configuring user-defined network interface names by using udev rules Copiar enlaceEnlace copiado en el portapapeles!
You can use udev rules to implement custom network interface names that reflect your organization’s requirements.
Procedure
Identify the network interface that you want to rename:
ip link show
# ip link show ... enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:00:5e:00:53:1a brd ff:ff:ff:ff:ff:ff ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow Record the MAC address of the interface.
Display the device type ID of the interface:
cat /sys/class/net/enp1s0/type 1
# cat /sys/class/net/enp1s0/type 1Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the
/etc/udev/rules.d/70-persistent-net.rulesfile, and add a rule for each interface that you want to rename:SUBSYSTEM=="net",ACTION=="add",ATTR{address}=="<MAC_address>",ATTR{type}=="<device_type_id>",NAME="<new_interface_name>"SUBSYSTEM=="net",ACTION=="add",ATTR{address}=="<MAC_address>",ATTR{type}=="<device_type_id>",NAME="<new_interface_name>"Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantUse only
70-persistent-net.rulesas a file name if you require consistent device names during the boot process. Thedracututility adds a file with this name to theinitrdimage if you regenerate the RAM disk image.For example, use the following rule to rename the interface with MAC address
00:00:5e:00:53:1atoprovider0:SUBSYSTEM=="net",ACTION=="add",ATTR{address}=="00:00:5e:00:53:1a",ATTR{type}=="1",NAME="provider0"SUBSYSTEM=="net",ACTION=="add",ATTR{address}=="00:00:5e:00:53:1a",ATTR{type}=="1",NAME="provider0"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Regenerate the
initrdRAM disk image:dracut -f
# dracut -fCopy to Clipboard Copied! Toggle word wrap Toggle overflow You require this step only if you need networking capabilities in the RAM disk. For example, this is the case if the root file system is stored on a network device, such as iSCSI.
Identify which NetworkManager connection profile uses the interface that you want to rename:
nmcli -f device,name connection show
# nmcli -f device,name connection show DEVICE NAME enp1s0 example_profile ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow Unset the
connection.interface-nameproperty in the connection profile:nmcli connection modify example_profile connection.interface-name ""
# nmcli connection modify example_profile connection.interface-name ""Copy to Clipboard Copied! Toggle word wrap Toggle overflow Temporarily, configure the connection profile to match both the new and the previous interface name:
nmcli connection modify example_profile match.interface-name "provider0 enp1s0"
# nmcli connection modify example_profile match.interface-name "provider0 enp1s0"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Reboot the system:
reboot
# rebootCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the device with the MAC address that you specified in the link file has been renamed to
provider0:ip link show
# ip link show provider0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 00:00:5e:00:53:1a brd ff:ff:ff:ff:ff:ff ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the connection profile to match only the new interface name:
nmcli connection modify example_profile match.interface-name "provider0"
# nmcli connection modify example_profile match.interface-name "provider0"Copy to Clipboard Copied! Toggle word wrap Toggle overflow You have now removed the old interface name from the connection profile.
Reactivate the connection profile:
nmcli connection up example_profile
# nmcli connection up example_profileCopy to Clipboard Copied! Toggle word wrap Toggle overflow
1.7. Configuring user-defined network interface names by using systemd link files Copiar enlaceEnlace copiado en el portapapeles!
You can use systemd link files to implement custom network interface names that reflect your organization’s requirements.
Prerequisites
- You must meet one of these conditions: NetworkManager does not manage this interface, or the corresponding connection profile uses the keyfile format.
Procedure
Identify the network interface that you want to rename:
ip link show
# ip link show ... enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:00:5e:00:53:1a brd ff:ff:ff:ff:ff:ff ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow Record the MAC address of the interface.
If it does not already exist, create the
/etc/systemd/network/directory:mkdir -p /etc/systemd/network/
# mkdir -p /etc/systemd/network/Copy to Clipboard Copied! Toggle word wrap Toggle overflow For each interface that you want to rename, create a
70-*.linkfile in the/etc/systemd/network/directory with the following content:[Match] MACAddress=<MAC_address> [Link] Name=<new_interface_name>
[Match] MACAddress=<MAC_address> [Link] Name=<new_interface_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantUse a file name with a
70-prefix to keep the file names consistent with theudevrules-based solution.For example, create the
/etc/systemd/network/70-provider0.linkfile with the following content to rename the interface with MAC address00:00:5e:00:53:1atoprovider0:[Match] MACAddress=00:00:5e:00:53:1a [Link] Name=provider0
[Match] MACAddress=00:00:5e:00:53:1a [Link] Name=provider0Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Regenerate the
initrdRAM disk image:dracut -f
# dracut -fCopy to Clipboard Copied! Toggle word wrap Toggle overflow You require this step only if you need networking capabilities in the RAM disk. For example, this is the case if the root file system is stored on a network device, such as iSCSI.
Identify which NetworkManager connection profile uses the interface that you want to rename:
nmcli -f device,name connection show
# nmcli -f device,name connection show DEVICE NAME enp1s0 example_profile ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow Unset the
connection.interface-nameproperty in the connection profile:nmcli connection modify example_profile connection.interface-name ""
# nmcli connection modify example_profile connection.interface-name ""Copy to Clipboard Copied! Toggle word wrap Toggle overflow Temporarily, configure the connection profile to match both the new and the previous interface name:
nmcli connection modify example_profile match.interface-name "provider0 enp1s0"
# nmcli connection modify example_profile match.interface-name "provider0 enp1s0"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Reboot the system:
reboot
# rebootCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the device with the MAC address that you specified in the link file has been renamed to
provider0:ip link show
# ip link show provider0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 00:00:5e:00:53:1a brd ff:ff:ff:ff:ff:ff ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the connection profile to match only the new interface name:
nmcli connection modify example_profile match.interface-name "provider0"
# nmcli connection modify example_profile match.interface-name "provider0"Copy to Clipboard Copied! Toggle word wrap Toggle overflow You have now removed the old interface name from the connection profile.
Reactivate the connection profile.
nmcli connection up example_profile
# nmcli connection up example_profileCopy to Clipboard Copied! Toggle word wrap Toggle overflow
1.8. Assigning alternative names to a network interface by using systemd link files Copiar enlaceEnlace copiado en el portapapeles!
With alternative interface naming, the kernel can assign additional names to network interfaces. You can use these alternative names in the same way as the normal interface names in commands that require a network interface name.
Prerequisites
- You must use ASCII characters for the alternative name.
- The alternative name must be shorter than 128 characters.
Procedure
Display the network interface names and their MAC addresses:
ip link show
# ip link show ... enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:00:5e:00:53:1a brd ff:ff:ff:ff:ff:ff ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow Record the MAC address of the interface to which you want to assign an alternative name.
If it does not already exist, create the
/etc/systemd/network/directory:mkdir -p /etc/systemd/network/
# mkdir -p /etc/systemd/network/Copy to Clipboard Copied! Toggle word wrap Toggle overflow For each interface that must have an alternative name, create a copy of the
/usr/lib/systemd/network/99-default.linkfile with a unique name and.linksuffix in the/etc/systemd/network/directory, for example:cp /usr/lib/systemd/network/99-default.link /etc/systemd/network/98-lan.link
# cp /usr/lib/systemd/network/99-default.link /etc/systemd/network/98-lan.linkCopy to Clipboard Copied! Toggle word wrap Toggle overflow Modify the file you created in the previous step. Rewrite the
[Match]section as follows, and append theAlternativeNameentries to the[Link]section:Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example, create the
/etc/systemd/network/70-altname.linkfile with the following content to assignprovideras an alternative name to the interface with MAC address00:00:5e:00:53:1a:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Regenerate the
initrdRAM disk image:dracut -f
# dracut -fCopy to Clipboard Copied! Toggle word wrap Toggle overflow Reboot the system:
reboot
# rebootCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Use the alternative interface name. For example, display the IP address settings of the device with the alternative name
provider:ip address show provider
# ip address show provider 2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:00:5e:00:53:1a brd ff:ff:ff:ff:ff:ff altname provider ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow