Linux Hint Posted January 5 Share Posted January 5 Predictable network interface names are: Stable across reboots Fixed/consistent even if the hardware is added or removed Fixed/consistent even if defective/damaged hardware is replaced Stateless and does not require any explicit configuration files For system security and ease of use, predictable network interface names are very important. So, major Linux distributions use “systemd” and “udev” to assign predictable names to the network interfaces of your computer. Currently, there are a few 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 the available network interface naming policies of Linux and show you how to switch to the one that you want. Topic of Contents: Available Network Interface Naming Policies The Network Interface Naming Policy Currently Being Used Changing the Network Interface Naming Policy Checking If the New Network Interface Naming Policy Is Being Used Configuring the Custom Names for Network Interfaces Conclusion Available Network Interface Naming Policies Currently, the available network interface naming policies are: kernel – In this policy, the kernel does not rename the predictable network devices, i.e. lo (the loopback interface) database – In this policy, the udev hardware database which is “hwdb” is used to assign the network device names. onboard – In this policy, the index number provided by the BIOS/firmware of your computer is used to name the onboard network devices, i.e. eno1, eno2. slot – In this policy, the PCIE hot-plug slot index number provided by the BIOS/firmware of your computer is used to name the network devices, i.e. ens1, ens2. path – In this policy, the physical location of the hardware is used to name the network devices, i.e. enp1s0, enp1s2, enp1s0f0, enp1s0f1. 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 Being Used The default network interface naming policy configuration file on most of the popular Linux distributions is in the “/usr/lib/systemd/network/99-default.link” path. 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/lib/systemd/network/99-default.link The order of the network interface naming policies to be used is listed in the “NamePolicy” section[1]. Here, “keep” has the highest priority. What “keep” does is if a name is already assigned to a network interface, systemd/udev will keep using the same name again and again. Then, it will try to set the kernel names. If the kernel naming policy fails, use the database, onboard, slot, and path, respectively. You can also set an alternative name for the network interfaces 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 depending on the order set in the “AlternativeNamesPolicy”. As you can see, the slot network interface naming policy, by default, is used to name the actual network interfaces and the path network interface naming policy is used to give an alternative name to the network interface on Ubuntu 22.04 LTS. A different naming policy and alternative naming policy may be used by default on other Linux distributions. $ ip a Changing the Network Interface Naming Policy To change the network interface naming policy, open the “/usr/lib/systemd/network/99-default.link” configuration file with the nano text editor as follows: $ sudo nano /usr/lib/systemd/network/99-default.link Type in 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 <Ctrl> + X followed by “Y” and <Enter> to save the “99-default.link” file. For the changes to take effect, reboot your computer as follows: $ sudo reboot Checking If the New Network Interface Naming Policy Is Being Used Once your computer boots, run the “ip” command to verify whether the network interface names changed accordingly. As you can see, the mac network interface naming policy is used to set the real names for the network interface and the path network interface naming policy is used to set the alternative names for the network interfaces. $ ip a 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 interfaces, respectively. Configuring the Custom Names for Network Interfaces Besides using the predefined network interface naming policies, you can also set the custom names for the network interfaces of your computer. To learn how to set the custom names for your network interfaces, read this article. Conclusion In this article, we discussed the available network interface naming policies of modern Linux distributions. We also showed you how to use the different network interface naming policies on Ubuntu/Debian, RHEL/Rocky Linux/CentOS/Fedora, and other Ubuntu/Debian-based or RPM-based modern Linux distributions. View the full article Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.