Thursday, March 21, 2019

Change network interface name from enpxxx to ethX

Tags: CentOS, Consistent network device naming, GRUB
----------

The CentOS 7.X use the consistent network device naming scheme by default. That make the Ethernet interface appearing as enpxxx.

Somebody and some old tools do not like it. For example, some license daemons for EDA tools require the HostID as the MAC address of the ethX interface.

To switch it back to the old ethX naming scheme:

1. Disable the NetworkManager
# systemctl disable NetworkManager

2. Update the boot option in the /etc/default/grub file. Locate the GRUB_CMDLINE_LINUX line and then insert the "net.ifnames=0 biosdevname=0" in it. For example:
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos_bhem/root rd.lvm.lv=centos_bhem/swap net.ifnames=0 biosdevname=0 rhgb quiet"

Note: Make sure the GRUB_CMDLINE_LINUX line is a single line. No line break is allowed.

3. Make the boot option effective.
For BIOS boot:
# grub2-mkconfig -o /boot/grub2/grub.cfg
For UEFI boot:
# grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg

4. Create configuration for the interface. For example:
# cd /etc/sysconfig/network-scripts/
# mv ifcfg-enp2s0 ifcfg-eth0
Then update the ifcfg-eth0 file, replacing 'enp2s0' by 'eth0'. For example:
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="dhcp"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="eth0"
UUID="a062bfa4-8820-4d64-bdeb-28b3f5052fce"
DEVICE="eth0"
ONBOOT="yes"

5. Reboot