Every Linux distribution sets a name for the network interfaces. Modern Linux distributions use “systemd” and “udev” to set the predictable network interface names (i.e. ens33, enp1s1, eno1, wlan0, enx0012dd0011ff). Besides that, you can also set the custom names for the network interfaces of your computer to keep the network configurations of your computer more readable/documented.
In this article, we will show you how to set the custom names for the network interfaces of your Linux distribution (Ubuntu/Debian/RHEL/Fedora/Rocky Linux and other modern Linux distributions that uses systemd).
Topic of Contents:
- Find the MAC Address of the Network Interface
- Renaming a Network Interface
- Verifying If the Network Interface Name Changed
- Conclusion
Find the MAC Address of the Network Interface
To rename a network interface, you need a way to match the network interface. You can use different properties of the network device, i.e. MAC address, PCIE device path, and so on to match the network interface. In this article, we will use the MAC address of the network interface to match the network interface while assigning a custom name for the network interface.
To find the current device name and MAC address of the network interfaces of your computer, you can use the “nmcli” command as follows:
You can also use the “ip” command as follows:
We showed you how to find the MAC address of the available network interfaces of your computer using the “nmcli” and “ip” commands. Both will give you the same results. But, we prefer the “nmcli” method since the output is more cleanly formatted.
Renaming a Network Interface
To rename a network interface on Ubuntu/Debian/RHEL/CentOS/Rocky Linux/Fedora and other popular Linux distributions that use “systemd”, you have to create the necessary configuration files in the “/etc/systemd/network” directory.
On your Linux distribution, the “/etc/systemd/network” directory might not be available. In that case, you can create it with the following command:
For demonstration, we rename the “ens224” network interface to “bridge0” which has the MAC address of 00:0C:29:57:FE:D6.
First, create a “systemd” network configuration file “10-bridge0.link” in the “/etc/systemd/network” and open it with the nano text editor.
NOTE: In the “10-bridge.link” file name, 10 is the priority number. If the priority number is not higher than the other network configurations, the network interface might not be renamed. If you need to rename multiple network interfaces, you can create a network configurations file for each network interface using the same priority number of 10 (just to be safe).
In the “10-bridge0.link” file, type in the following lines and make sure to replace <MAC-address> and <New-Network-Interface-Name> with the MAC address and the new name of the network interface, respectively.
MACAddress=<MAC-address>
[Link]
Name=<New-Network-Interface-Name>
Once you’re done, press <Ctrl> + X followed by “Y” and <Enter> to save the “10-bridge0.link” configuration file.
For the changes to take effect, reboot your computer with the following command:
Verifying If the Network Interface Name Changed
NOTE: Once the network interface name is changed (to bridge0 in this case), the network interface might get disconnected. You can bring it up (if configured via DHCP) with the following command:
To confirm whether the network interface name is changed, use the “nmcli” or “ip” command as you did previously. As you can see, the network interface name is changed to “bridge0”.
We changed the name of the other network interfaces for the demonstration. The network configuration now looks much more readable.
Conclusion
In this article, we showed you how to find the MAC address of the network interfaces of your Linux system. We also showed you how to set a custom name for the network interfaces of your Linux system.