Chapter 1. Consistent network interface device naming

Red Hat Enterprise Linux provides methods for consistent and predictable device naming for network interfaces. These features help locating and differentiating network interfaces.

The kernel assigns names to network interfaces by concatenating a fixed prefix and a number that increases as the kernel initialize the network devices. For instance, eth0 would represent the first device being probed on start-up. However, these names do not necessarily correspond to labels on the chassis. Modern server platforms with multiple network adapters can encounter non-deterministic and counter-intuitive naming of these interfaces. This affects both network adapters embedded on the system board and add-in adapters.

In Red Hat Enterprise Linux, 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 places.
  • Defective hardware can be seamlessly replaced.

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:

SchemeDescriptionExample

1

Device names incorporate firmware or BIOS-provided index numbers for onboard devices. If this information is not available or applicable, udev uses scheme 2.

eno1

2

Device names incorporate firmware or BIOS-provided PCI Express (PCIe) hot plug slot index numbers. If this information is not available or applicable, udev uses scheme 3.

ens1

3

Device names incorporate the physical location of the connector of the hardware. If this information is not available or applicable, udev uses scheme 5.

enp2s0

4

Device names incorporate the MAC address. Red Hat Enterprise Linux does not use this scheme by default, but administrators can optionally use it.

enx525400d5e0fb

5

The traditional unpredictable kernel naming scheme. If udev cannot apply any of the other schemes, the device manager uses this scheme.

eth0

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 following list describes the order in which udev processes these rules and what actions these rules are responsible for:

  1. The /usr/lib/udev/rules.d/60-net.rules file defines that the /lib/udev/rename_device helper utility searches for the HWADDR 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 the DEVICE parameter of the file.
  2. The /usr/lib/udev/rules.d/71-biosdevname.rules file defines that the biosdevname utility renames the interface according to its naming policy, provided that it was not renamed in the previous step.
  3. The /usr/lib/udev/rules.d/75-net-description.rules file defines that udev examines the network interface device and sets the properties in udev-internal variables, that will be processed in the next step. Note that some of these properties might be undefined.
  4. The /usr/lib/udev/rules.d/80-net-setup-link.rules file calls the net_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 of udev. 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 to mac for media access control (MAC) address-based interface names.

  5. The /usr/lib/udev/rules.d/80-net-setup-link.rules file defines that udev renames the interface based on the udev-internal parameters in the following order:

    1. ID_NET_NAME_ONBOARD
    2. ID_NET_NAME_SLOT
    3. 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. This section describes the naming scheme when Red Hat Enterprise Linux is installed on a x86_64 platform.

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 function 0 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 not 0.

  • [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.

1.5. Disabling consistent interface device naming during the installation

This section describes how to disable consistent interface device naming during the installation.

Warning

Red Hat recommends not to disable consistent device naming. Disabling consistent device naming can cause different kind of problems. For example, if you add another network interface card to the system, the assignment of the kernel device names, such as eth0, is no longer fixed. Consequently, after a reboot, the Kernel can name the device differently.

Procedure

  1. Boot the Red Hat Enterprise Linux 9 installation media.
  2. In the boot manager, select Install Red Hat Enterprise Linux 9, and press the Tab key to edit the entry.
  3. Append the net.ifnames=0 parameter to the kernel command line:

    vmlinuz... net.ifnames=0
  4. Press Enter to start the installation.

1.6. Disabling consistent interface device naming on an installed system

This section describes how to disable consistent interface device naming on a RHEL system that is already installed.

Warning

Red Hat recommends not to disable consistent device naming. Disabling consistent device naming can cause different kinds of problems. For example, if you add another network interface card to the system, the assignment of the kernel device names, such as eth0, is no longer fixed. Consequently, after a reboot, the Kernel can name the device differently.

Prerequisites

  • The system uses consistent interface device naming, which is the default.

Procedure

  1. Edit the /etc/default/grub file and append the net.ifnames=0 parameter to the GRUB_CMDLINE_LINUX variable:

    GRUB_CMDLINE_LINUX="... net.ifnames=0"
  2. Rebuild the grub.cfg file:

    • On a system with UEFI boot mode:

      # grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
    • On a system with legacy boot mode:

      # grub2-mkconfig -o /boot/grub2/grub.cfg
  3. Display the current profile names and the associated device names:

    # nmcli -f NAME,DEVICE,FILENAME connection show
    NAME           DEVICE  FILENAME
    System enp1s0  enp1s0  /etc/sysconfig/network-scripts/ifcfg-enp1s0
    System enp7s0  enp7s0  /etc/NetworkManager/system-connections/enp7s0.nmconnection

    Note which profile name and configuration file is associated with each device.

  4. Remove HWADDR parameters from all connection profiles:

    # sed -i '/^HWADDR=/d' /etc/sysconfig/network-scripts/ifcfg-enp1s0 /etc/NetworkManager/system-connections/enp7s0.nmconnection
  5. Display the MAC addresses that are associated with the Ethernet devices:

    # ip link show
    ...
    2: enp1s0: <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: enp7s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
        link/ether 00:53:00:b6:87:c6 brd ff:ff:ff:ff:ff:ff
  6. Reboot the host:

    # reboot
  7. After the reboot, display the Ethernet devices and identify the new interface name based on the MAC address:

    # ip link show
    ...
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
        link/ether 00:53:00:b6:87:c6 brd ff:ff:ff:ff:ff:ff
    3: eth1: <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

    If you compare the current output with the previous one:

    • Interface enp7s0 (MAC address 00:53:00:b6:87:c6) is now named eth0.
    • Interface enp1s0 (MAC address 00:53:00:c5:98:1c) is now named eth1.
  8. Rename the configuration file:

    # mv /etc/NetworkManager/system-connections/enp7s0.nmconnection /etc/NetworkManager/system-connections/eth0.nmconnection
    # mv /etc/sysconfig/network-scripts/ifcfg-enp1s0 /etc/sysconfig/network-scripts/ifcfg-eth1
  9. Reload NetworkManager:

    # nmcli connection reload
  10. If no profile name is set in the configuration files, NetworkManager uses a default value. To determine the current profile name after you renamed and reloaded the connections, enter:

    # nmcli -f NAME,DEVICE,FILENAME connection show
    NAME           FILENAME
    System enp7s0  /etc/NetworkManager/system-connections/eth0.nmconnection
    System enp1s0  /etc/sysconfig/network-scripts/ifcfg-eth1

    You require the profile names in the next step.

  11. Rename the NetworkManager connection profiles and update the interface name in each profile:

    # nmcli connection modify "System enp7s0" connection.id eth0 connection.interface-name eth0
    # nmcli connection modify "System enp1s0" connection.id eth1 connection.interface-name eth1
  12. Reactivate the NetworkManager connections:

    # nmcli connection up eth0
    # nmcli connection up eth1

1.7. Customizing the prefix of Ethernet interfaces

You can customize the prefix of Ethernet interface names during the Red Hat Enterprise Linux installation.

Important

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, and em.

Procedure

  1. Boot the Red Hat Enterprise Linux installation media.
  2. In the boot manager:

    1. Select the Install Red Hat Enterprise Linux <version> entry, and press Tab to edit the entry.
    2. Append net.ifnames.prefix=<prefix> to the kernel options.
    3. Press Enter to start the installer.
  3. 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.8. Additional resources

  • See the udev(7) man page for details about the udev device manager.