How to change network interface naming policy on Ubuntu/Debian/RHEL/CentOS/Fedora/Rocky Linux

H
The predictable network interface names are:

  1. stable during reboot
  2. Stable/consistent even when adding or removing hardware
  3. Stable/consistent even when replacing faulty/damaged hardware
  4. Stateless and requires no explicit configuration files

For system security and ease of use, predictable network interface names are very important. Therefore, major Linux distributions use “systemd” and “udev” to assign predictable names to your computer's network interfaces.

Currently, there are some network interface naming policies that you can use on Ubuntu, Debian, RHEL, CentOS, Fedora, Rocky Linux, and other popular Debian/Ubuntu-based or RPM-based Linux distributions. In this article, we will discuss Linux's available network interface naming policies and show you how to switch to the one you want.

Contents:

  1. Available network interface naming policies
  2. The network interface naming policy currently in use
  3. Changing network interface naming policy
  4. Checking if the new network interface naming policy is being used
  5. Configure a custom name for a network interface
  6. conclusion

Available network interface naming policies

Currently, the available network interface naming policies are:

  1. kernel – In this policy, the kernel does not rename predicted network devices, i.e. LO (loopback interface)
  2. database – In this policy, the udev hardware database which is “hwdb” is used to specify the network device name.
  3. riding – In this policy, the index numbers provided by your computer's BIOS/firmware are used to name the onboard network devices, i.e. eno1, eno2.
  4. hole – In this policy, the PCIE hot-plug slot index number provided by your computer's BIOS/firmware is used to name the network device, i.e. ens1, ens2.
  5. path – In this policy, the physical location of the hardware is used to name the network devices, i.e. enp1s0, enp1s2, enp1s0f0, enp1s0f1.
  6. mac – In this policy, the MAC address of the network device is appended to the network interface name, i.e. enx000c294cd7e8.

The network interface naming policy currently in use

The default network interface naming policy configuration file on most popular Linux distributions is in the path “/usr/lib/systemd/network/99-default.link”.

You can open the default network interface naming policy configuration file “/usr/lib/systemd/network/99-default.link” with the Nano text editor as follows:

, sudo nano ,usr,liberalization,systemd,network,99-default.link

The order of network interface naming policies used is listed in the “NamePolicy” section[1],

Here, “Keep” has the highest priority. What “keep” does is that if a name is already assigned to a network interface, systemd/udev will keep using the same name over and over again.

Then, it will try to set the kernel name. If the kernel naming policy fails, use database, onboard, slot, and path, respectively.

You can also set an alternative name for the network interface using the “AlternativeNamesPolicy” option in the same way[2], A naming policy that is not used for actual network interface naming is used as an alternative naming policy based on the order set in “Alternate Name Policy”.

A screenshot of computer details is automatically generatedA screenshot of computer details is automatically generated

As you can see, the slot network interface naming policy is, by default, used to name the actual network interface and the path network interface naming policy is used to name the alternative name to the network interface on Ubuntu 22.04 LTS. goes. On other Linux distributions a different naming policy and alternative naming policy may be used by default.

A screenshot of computer details is automatically generatedA screenshot of computer details is automatically generated

Changing network interface naming policy

To change the network interface naming policy, open the “/usr/lib/systemd/network/99-default.link” configuration file with a nano text editor as follows:

, sudo nano ,usr,liberalization,systemd,network,99-default.link

Type your desired network interface naming policy in the “NamePolicy” section and the alternative network interface naming policy in the “AlternativeNamePolicy” section.

Once you're done, press , x followed by “Y” and <दर्ज करें> To save the “99-default.link” file.

A screenshot of computer details is automatically generatedA screenshot of computer details is automatically generated

For the changes to take effect, reboot your computer as follows:

Checking if the new network interface naming policy is being used

Once your computer boots up, run the “ip” command to verify whether the network interface names have changed accordingly. As you can see, the MAC network interface naming policy is used to set the real name for the network interface and the path network interface naming policy is used to set the alternative name for the network interface.

A screenshot of computer details is automatically generatedA screenshot of computer details is automatically generated

In this example, we used the path naming policy for the real name and the MAC naming policy for the alternative name of the network interface, respectively.

A screenshot of computer program details is automatically generatedA screenshot of computer program details is automatically generated

Configure a custom name for a network interface

In addition to using predefined network interface naming policies, you can also set custom names for your computer's network interface. Read this article to learn how to set a custom name for your network interface.

conclusion

In this article, we discussed the available network interface naming policies of modern Linux distributions. We also showed you how to use different network interface naming policies on Ubuntu/Debian, RHEL/Rocky Linux/CentOS/Fedora, and other Ubuntu/Debian-based or RPM-based modern Linux distributions.

Add comment

By Ranjan