How to rename the network interface in CentOS/RHEL7
I think everyone noticed that in Linux 7 network interface name has been changed from eth[0,1..] to ens. But in some organization they what to use eth as a standard network interface name. In this article we will explain how to can change the network interface name.
See Also:
- Install Secure Samba Server in CentOS/RHEL 7/8
- How to Install Samba Server in CentOS/RHEL 7/8 Password Less
- How to Migrate from CentOS 8 to AlmaLinux 8.6
- How to Set a Custom SSH Warning Banner and MOTD in Linux
- Create ASCII Text Banners in Terminal in Linux Using Figlet Tool
Grub Configuration:
First we need to edit grub configuration file to append some parameters.
# vim /etc/default/grub
Locate the line “GRUB_CMDLINE_LINUX=” and append the following parameter :
net.ifnames=0 biosdevname=0
For Eq:
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet net.ifnames=0 biosdevname=0"
Rebuilt Grub Configuration:
After implementing the changes in grub configuration file we need to rebuilt the grub configuration file so the changes will reflect.
# grub2-mkconfig -o /boot/grub2/grub.cfg
Network Configuration:
Copy or move the network configuration file from ens to eth and change the Device and Name parameter in network file.
# mv /etc/sysconfig/network-scripts/ifcfg-ens /etc/sysconfig/network-scripts/ifcfg-eth0
# vim /etc/sysconfig/network-scripts/ifcfg-eth0
Change the following values from the old to the new interface name :
NAME=
DEVICE=
After completing all the above steps reboot the server to reflect the changes.
# reboot
Enjoy it!