Linux Network Interface Naming

From Leo's Notes
Last edited on 20 June 2020, at 18:23.

Traditionally, network interfaces on Linux are enumerated as eth[0...n], where the first device being probed on start up is assigned eth0 and so on. Modern Linux utilizing systemd will assign network interfaces based on a Predictable Network Interface naming scheme which corresponds the network name to its hardware location. For example, an interface is named wlp2p1 because it is a wireless device located at a PCI bus 2, slot 1. The motivation for this is to deterministically set network adapter names on systems with multiple adapters.

Predictable Network Naming[edit | edit source]

Systems using the predictable network naming scheme will be named according to the following (simplified) rules. For the full description of these rules in greater detail, see the Red Hat documentation for RHEL 8 on predictable network naming.

Prefix Suffix
  • en - ethernet
  • wl - wireless LAN
  • ww - wireless wide area network
  • oN - onboard device, where N is the onboard index
  • sN - hot plug, where N is the slot index
  • xMAC - based on MAC address
  • pN/sX - for devices connected on a bus, where N is the bus number and X is the slot number.

For example: eno0 is the first onboard ethernet device, while enp0s0 is the first ethernet device connected to the first bus on the first slot.

Revert back to the traditional eth[0..N] naming scheme[edit | edit source]

You can revert back the old naming scheme using any one of the following methods as outlined on this systemd page.

  1. You create your own manual naming scheme by creating your own custom.link files within /etc/systemd/network/ which defines the specific name you wish to use. The description for this file is outlined at https://www.freedesktop.org/software/systemd/man/systemd.link.html
    # Match based on MAC address (and device path if uncommented)
    [Match]
    MACAddress=00:a0:de:63:7a:e6
    # Path=pci-0000:02:00.0-*
    
    # Link properties
    [Link]
    Name=eth0
    
    In the example above, the device matching the given MAC address will have its name set to eth0.
  2. You pass net.ifnames=0 to the kernel on boot by setting it in the boot loader. This is not recommended on systems with multiple network interfaces as they may be assigned names inconsistently across reboots. This should be safe on systems with only one network adapter. You set this kernel argument this by editing /etc/default/grub, appending net.ifnames=0 to the kernel command line, applying it with grub2-mkconfig -o /boot/grub2/grub.cfg, and then rebooting.
  3. You disable the assignment of fixed names by symlinking /etc/systemd/network/99-default.link to /dev/null and rebuilding initrd.

Renumbering network interfaces[edit | edit source]

If your system is relying on udev rather than systemd-udevd (and thereby using systemd's predictable network interfacing naming scheme), after inserting and removing network interfaces, your network interface now has a non-zero number. For example, after inserting and replacing a network interface twice, the primary interface is now named eth2. Systems affected by this problem includes RHEL 6 or prior.

To rename interfaces so that it starts back at eth0, edit the udev rules defined in /etc/udev/rules.d/70-persistent-net.rules. Remove lines defining the extraneous interfaces that you don't want. Once done, ensure that your network configs in /etc/sysconfig/network-scripts/ matches up to your new network interface names.

Reboot to apply.

See Also[edit | edit source]