How To : Change Network Interfaces in Centos 7

  Operating System, Tools

To keep our infra networks standardize, we might need to change the Interface name for our INFRA servers.

1. Edit file /etc/default/grub and add ‘net.ifnames=0’ in ‘GRUB_CMDLINE_LINUX’ line.

Example :


GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet net.ifnames=0"
GRUB_DISABLE_RECOVERY="true"

2. Rebuild the GRUB


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

3.Proceed to rename the Interface name, make sure you edit the ‘NAME’ and ‘DEVICE’ in the interface config.

Example:


cd /etc/sysconfig/network-scripts
mv ifcfg-ens32 ifcfg-eth0


TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
#IPV6INIT=yes
#IPV6_AUTOCONF=yes
#IPV6_DEFROUTE=yes
#IPV6_PEERDNS=yes
#IPV6_PEERROUTES=yes
#IPV6_FAILURE_FATAL=no
#IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eth0
UUID=9fe2de3d-e242-42c8-97c7-a3fab02e247f
DEVICE=eth0
ONBOOT=yes
IPADDR=xx.xx.xx.xx
NETMASK=255.255.255.192
GATEWAY=xx.xx.xx.xx

4. Perform a reboot to initiate the changes.


init 6