How to rename interfaces in Linux

MAC addresses must be specified in lowercase. For some OS configurations, the configuration files use interface names like int0 / int1 or ext0 / ext1. The interface names must be consistent across all configuration files.

Step 1: Create or modify the udev rules file

Create the /etc/udev/rules.d/70-persistent-net.rules file if it does not exist:

sudo nano /etc/udev/rules.d/70-persistent-net.rules

Add rules using the MAC addresses of your network interfaces:

SUBSYSTEM=="net",ACTION=="add",DRIVERS=="?*",ATTR{address}=="a0:36:9f:7f:40:88",ATTR{type}=="1",NAME="int1"
SUBSYSTEM=="net",ACTION=="add",DRIVERS=="?*",ATTR{address}=="a0:36:9f:57:84:94",ATTR{type}=="1",NAME="int2"
SUBSYSTEM=="net",ACTION=="add",DRIVERS=="?*",ATTR{address}=="a0:36:9f:7f:40:8a",ATTR{type}=="1",NAME="ext1"
SUBSYSTEM=="net",ACTION=="add",DRIVERS=="?*",ATTR{address}=="a0:36:9f:57:84:96",ATTR{type}=="1",NAME="ext2"

Replace the MAC addresses with the actual addresses of your network interfaces and set the desired names.

Step 2: Disable predictable interface names in GRUB

In the file /etc/default/grub, add the parameters net.ifnames=0 and biosdevname=0 to the GRUB_CMDLINE_LINUX line:

GRUB_CMDLINE_LINUX="... net.ifnames=0 biosdevname=0"

Note: For Ubuntu 14, 16, and Debian 9, specify only net.ifnames=0 (omit biosdevname=0):

GRUB_CMDLINE_LINUX_DEFAULT="net.ifnames=0"

Step 3: Recreate the GRUB configuration

For CentOS 7:

grub2-mkconfig -o /boot/grub2/grub.cfg

For Ubuntu / Debian:

sudo update-grub

Step 4: Reboot

sudo reboot

Note: For CentOS 6 and Ubuntu 14.04, it is not necessary to update GRUB. It is sufficient to specify the interface names in /etc/udev/rules.d/70-persistent-net.rules and reboot.

After renaming, update your network configuration files to use the new interface names before rebooting, or the server may lose network connectivity.

On this page