Renaming Network Interfaces in Linux

Once, after updating the i40e driver for Intel network adapters, I noticed that the names of the network interfaces had changed, and after rebooting the operating system, the names also periodically changed.

Therefore, before updating the driver, it is necessary to save the mac addresses of the necessary network interfaces, information about the mac address, network adapter model, on which network interfaces the link went up, you can see, for example, with the commands below:

lshw -C network | less
dmesg -T | less
ip a
ls /sys/class/net/
ls /sys/class/net/enp0s3/
cat /sys/class/net/enp0s3/address

To name the network interface, for example in Ubuntu, open the following file in a text editor:

nano /etc/udev/rules.d/70-snap.snapd.rules

And add a line (in which we specify “address” – the mac address of the desired network interface, KERNEL – the template into which the old name falls, for example eth*, enp*, eno*, ens* and “NAME” – its desired new name):

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="6c:b3:00:00:d3:92", ATTR{type}=="1", KERNEL=="eth*", NAME="wan"

When changing the names of network interfaces, also do not forget to correct them in the network configuration, for example, in /etc/network/interfaces or /etc/netplan/. Or let’s make the names of the network interfaces as they are described in the network configuration and were previously before the driver update.

You can also make changes to a separate file, for example:

nano /etc/udev/rules.d/1-user-udev.rules
KERNEL=="eth*", ATTR{address}=="6c:b3:00:00:d3:92", NAME="ens2"
KERNEL=="eth*", ATTR{address}=="6c:b3:00:00:d3:90", NAME="ens4"

Let’s reboot the operating system and make sure that the network interface has been successfully renamed and has the correct network settings.

See also my articles:
How to return ethX names to network interfaces
How to view information about the network adapter in Linux
Intel i40e driver update

Leave a comment

Leave a Reply