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.
In addition, you can read the reasons why the naming schema was changed for predictable network interface names or follow a discussion on the Red Hat customer portal about network device naming in RHEL 7.
Source: Nerdy’s blog.