As people were complaining about network interface names changing each time a new one was added, it was decided to call a network interface according to its physical location. The details of the naming convention are available in the RHEL 7 Networking Guide.
However, having a network interface called enp2s0 or enp4s2f0 doesn’t satisfy everybody.
Hopefully, a solution exists to restore the previous behavior.
The old naming convention
To restore the old naming convention, you need to edit the /etc/default/grub file and add net.ifnames=0 biosdevname=0 at the end of the GRUB_CMDLINE_LINUX variable:
GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/swap vconsole.keymap=us crashkernel=auto rd.lvm.lv=centos/root vconsole.font=latarcyrheb-sun16 rhgb quiet net.ifnames=0 biosdevname=0"
Then, test the new configuration to see if no mistake has been made:
Note: When preparing this tutorial, I forgot the last quote in the GRUB_CMDLINE_LINUX variable.
I got the following error: /etc/default/grub: line 7: unexpected EOF while looking for matching `”‘.
This is only to remind you that testing can be useful!
If everything is fine, update the grub2 configuration:
# grub2-mkconfig -o /boot/grub2/grub.cfg Generating grub configuration file ... Found linux image: /boot/vmlinuz-3.10.0-123.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-123.el7.x86_64.img Found linux image: /boot/vmlinuz-3.10.0-123.9.3.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-123.9.3.el7.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-eda26f60d4c948d09cd50d9086a87fcc Found initrd image: /boot/initramfs-0-rescue-eda26f60d4c948d09cd50d9086a87fcc.img done
Update the network interface configuration file (here the initial interface name was enp2s0 and the new one is eth0):
# cd /etc/sysconfig/network-scripts # cp ifcfg-enp2s0 ifcfg-eth0
Edit the ifcfg-eth0 file and replace the network interface name in the NAME variable with “eth0“.
After a reboot, everything should be OK.
Source: Nerdy’s blog.
In addition, you can read the reasons why the naming schema was changed for predictable network interface names, follow a discussion on the Red Hat customer portal about network device naming in RHEL 7 or read this tutorial about Changing Ethernet Device Names in EL7.
Caution: When upgrading to RHEL 7.3 and using very long network interface names (for example eno16780032), specific precautions need to be taken before any reboot (see here and here).
Thank you for your detailed and complete information about consistent network interface naming.