Red Hat Training
A Red Hat training course is available for RHEL 8
Chapter 1. Consistent network interface device naming
The Linux kernel assigns names to network interfaces by combining a fixed prefix and a number that increases as the kernel initializes the network devices. For instance, eth0
represents the first device being probed on start-up. If you add another network interface card to the system, the assignment of the kernel device names is no longer fixed. Consequently, after a reboot, the kernel can name the device differently.
To solve this problem, the udev
device manager supports a number of different naming schemes. By default, udev
assigns fixed names based on firmware, topology, and location information. This has the following advantages:
- Device names are fully predictable.
- Device names stay fixed even if you add or remove hardware, because no re-enumeration takes place.
- Defective hardware can be seamlessly replaced.
Red Hat does not support systems with consistent device naming disabled. For further details, see Is it safe to set net.ifnames=0?
1.1. Network interface device naming hierarchy
If consistent device naming is enabled, which is the default in Red Hat Enterprise Linux, the udev
device manager generates device names based on the following schemes:
Scheme | Description | Example |
---|---|---|
1 |
Device names incorporate firmware or BIOS-provided index numbers for onboard devices. If this information is not available or applicable, |
|
2 |
Device names incorporate firmware or BIOS-provided PCI Express (PCIe) hot plug slot index numbers. If this information is not available or applicable, |
|
3 |
Device names incorporate the physical location of the connector of the hardware. If this information is not available or applicable, |
|
4 | Device names incorporate the MAC address. Red Hat Enterprise Linux does not use this scheme by default, but administrators can optionally use it. |
|
5 |
The traditional unpredictable kernel naming scheme. If |
|
By default, Red Hat Enterprise Linux selects the device name based on the NamePolicy
setting in the /usr/lib/systemd/network/99-default.link
file. The order of the values in NamePolicy
is important. Red Hat Enterprise Linux uses the first device name that is both specified in the file and that udev
generated.
If you manually configured udev
rules to change the name of kernel devices, those rules take precedence.
1.2. How the network device renaming works
By default, consistent device naming is enabled in Red Hat Enterprise Linux. The udev
device manager processes different rules to rename the devices. The udev
service processes these rules in the following order:
-
The
/usr/lib/udev/rules.d/60-net.rules
file defines that the/lib/udev/rename_device
helper utility searches for theHWADDR
parameter 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 theDEVICE
parameter of the file. -
The
/usr/lib/udev/rules.d/71-biosdevname.rules
file defines that thebiosdevname
utility renames the interface according to its naming policy, provided that it was not renamed in the previous step. -
The
/usr/lib/udev/rules.d/75-net-description.rules
file defines thatudev
examines the network interface device and sets the properties inudev
-internal variables that will be processed in the next step. Note that some of these properties might be undefined. The
/usr/lib/udev/rules.d/80-net-setup-link.rules
file calls thenet_setup_link
udev
built-in which then applies the policy. The following is the default policy that is stored in the/usr/lib/systemd/network/99-default.link
file:[Link] NamePolicy=kernel database onboard slot path MACAddressPolicy=persistent
With this policy, if the kernel uses a persistent name,
udev
does not rename the interface. If the kernel does not use a persistent name,udev
renames the interface to the name provided by the hardware database ofudev
. If this database is not available, Red Hat Enterprise Linux falls back to the mechanisms described above.Alternatively, set the
NamePolicy
parameter in this file tomac
for media access control (MAC) address-based interface names.The
/usr/lib/udev/rules.d/80-net-setup-link.rules
file defines thatudev
renames the interface based on theudev
-internal parameters in the following order:-
ID_NET_NAME_ONBOARD
-
ID_NET_NAME_SLOT
-
ID_NET_NAME_PATH
If one parameter is not set,
udev
uses the next one. If none of the parameters are set, the interface is not renamed.-
Steps 3 and 4 implement the naming schemes 1 to 4 described in Network interface device naming hierarchy.
Additional resources
1.3. Predictable network interface device names on the x86_64 platform explained
When the consistent network device name feature is enabled, the udev
device manager creates the names of devices based on different criteria. The interface name starts with a two-character prefix based on the type of interface:
-
en
for Ethernet -
wl
for wireless LAN (WLAN) -
ww
for wireless wide area network (WWAN)
Additionally, one of the following is appended to one of the above-mentioned prefix based on the schema the udev
device manager applies:
-
o<on-board_index_number>
s<hot_plug_slot_index_number>[f<function>][d<device_id>]
Note that all multi-function PCI devices have the
[f<function>]
number in the device name, including the function0
device.-
x<MAC_address>
[P<domain_number>]p<bus>s<slot>[f<function>][d<device_id>]
The
[P<domain_number>]
part defines the PCI geographical location. This part is only set if the domain number is not0
.[P<domain_number>]p<bus>s<slot>[f<function>][u<usb_port>][…][c<config>][i<interface>]
For USB devices, the full chain of port numbers of hubs is composed. If the name is longer than the maximum (15 characters), the name is not exported. If there are multiple USB devices in the chain,
udev
suppresses the default values for USB configuration descriptors (c1
) and USB interface descriptors (i0
).
1.4. Predictable network interface device names on the System z platform explained
When the consistent network device name feature is enabled, the udev
device manager on the System z platform creates the names of devices based on the bus ID. The bus ID identifies a device in the s390 channel subsystem.
For a channel command word (CCW) device, the bus ID is the device number with a leading 0.n
prefix where n
is the subchannel set ID.
Ethernet interfaces are named, for example, enccw0.0.1234
. Serial Line Internet Protocol (SLIP) channel-to-channel (CTC) network devices are named, for example, slccw0.0.1234
.
Use the znetconf -c
or the lscss -a
commands to display available network devices and their bus IDs.
Red Hat Enterprise Linux also supports predictable and persistent interface names for RDMA over Converged Ethernet (RoCE) Express PCI functions. Two identifiers provide predictable interface names: user identifier (UID) and function identifier (FID). On a system to get UID-based predictable interface names, enforce UID uniqueness, which is the preferred naming scheme. If no unique UIDs are available, then RHEL uses FIDs to set predictable interface names.
1.5. Customizing the prefix of Ethernet interfaces during the installation
You can customize the prefix of Ethernet interface names during the Red Hat Enterprise Linux installation.
Red Hat does not support customizing the prefix using the prefixdevname
utility on already deployed systems.
After the RHEL installation, the udev
service names Ethernet devices <prefix>.<index>
. For example, if you select the prefix net
, RHEL names Ethernet interfaces net0
, net1
, and so on.
Prerequisites
The prefix you want to set meets the following requirements:
- It consists of ASCII characters.
- It is an alpha-numeric string.
- It is shorter than 16 characters.
-
It does not conflict with any other well-known prefix used for network interface naming, such as
eth
,eno
,ens
, andem
.
Procedure
- Boot the Red Hat Enterprise Linux installation media.
In the boot manager:
-
Select the
Install Red Hat Enterprise Linux <version>
entry, and press Tab to edit the entry. -
Append
net.ifnames.prefix=<prefix>
to the kernel options. - Press Enter to start the installer.
-
Select the
- Install Red Hat Enterprise Linux.
Verification
After the installation, display the Ethernet interfaces:
# 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:53:00:c5:98:1c brd ff:ff:ff:ff:ff:ff 3: net1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:53:00:c2:39:9e brd ff:ff:ff:ff:ff:ff ...
1.6. Assigning user-defined network interface names using udev rules
The udev
device manager supports a set of rules to customize the interface names.
Procedure
Display all network interfaces and their MAC addresses:
# ip link list enp6s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether b4:96:91:14:ae:58 brd ff:ff:ff:ff:ff:ff enp6s0f1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether b4:96:91:14:ae:5a brd ff:ff:ff:ff:ff:ff enp4s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:90:fa:6a:7d:90 brd ff:ff:ff:ff:ff:ff
Create the file
/etc/udev/rules.d/70-custom-ifnames.rules
with the following contents:SUBSYSTEM=="net",ACTION=="add",ATTR{address}=="b4:96:91:14:ae:58",ATTR{type}=="1",NAME="provider0" SUBSYSTEM=="net",ACTION=="add",ATTR{address}=="b4:96:91:14:ae:5a",ATTR{type}=="1",NAME="provider1" SUBSYSTEM=="net",ACTION=="add",ATTR{address}=="00:90:fa:6a:7d:90",ATTR{type}=="1",NAME="dmz"
These rules match the MAC address of the network interfaces and rename them to the name given in the NAME property. In these examples, ATTR{type} parameter value 1 defines that the interface is of type Ethernet.
Verification
Reboot the system.
# reboot
Verify that interface names for each MAC address match the value you set in the
NAME
parameter of the rule file:# ip link show provider0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether b4:96:91:14:ae:58 brd ff:ff:ff:ff:ff:ff altname enp6s0f0 provider1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether b4:96:91:14:ae:5a brd ff:ff:ff:ff:ff:ff altname enp6s0f1 dmz: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 00:90:fa:6a:7d:90 brd ff:ff:ff:ff:ff:ff altname enp4s0f0
Additional resources
-
udev(7)
man page -
udevadm(8)
man page -
/usr/src/kernels/<kernel_version>/include/uapi/linux/if_arp.h
provided by thekernel-doc
package
1.7. Assigning user-defined network interface names using systemd link files
Create a naming scheme by renaming network interfaces to provider0
.
Procedure
Display all interfaces names and their MAC addresses:
# ip link show enp6s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether b4:96:91:14:ae:58 brd ff:ff:ff:ff:ff:ff enp6s0f1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether b4:96:91:14:ae:5a brd ff:ff:ff:ff:ff:ff enp4s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 00:90:fa:6a:7d:90 brd ff:ff:ff:ff:ff:ff
For naming the interface with MAC address b4:96:91:14:ae:58 to provider0, create the /etc/systemd/network/70-custom-ifnames.link file with following contents:
[Match] MACAddress=b4:96:91:14:ae:58 [Link] Name=provider0
This link file matches a MAC address and renames the network interface to the name set in the
Name
parameter.
Verification
Reboot the system:
# reboot
Verify that the device with the MAC address you specified in the link file has been assigned to
provider0
:# ip link show provider0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether b4:96:91:14:ae:58 brd ff:ff:ff:ff:ff:ff
Additional resources
-
systemd.link(5)
man page