RedHat 8 or CentOS 8 uses a consistent and predictable device name for network interfaces. By default, udev assigns fixed names based on firmware, topology, and location information. So, to disable the predictable naming rule and change your network device name from enp0s3 or ens160 to old name eth0, follow the below steps:
01- First, check your current Network Interface Name using the nmcli
tool, in my case the device name is called ens160
# nmcli con show
NAME UUID TYPE DEVICE
ens160 d0b9a4d5-0a50-4577-a115-41a1eceb943c ethernet ens160
02- Edit the /etc/default/grub
file and append the net.ifnames=0
and biosdevname=0
parameters to the GRUB_CMDLINE_LINUX
variable as below:
vi /etc/default/grub
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 resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet net.ifnames=0 biosdevname=0"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true
03- Next, we need to rebuild the grub.cfg
file:
a- On a system with UEFI boot mode:
# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
b- On a system with legacy boot mode, run the below command:
# grub2-mkconfig -o /boot/grub2/grub.cfg
04- Now, we must manually update the interface names configuration file as below:
# mv /etc/sysconfig/network-scripts/ifcfg-ens160 /etc/sysconfig/network-scripts/ifcfg-eth0 $ sed -i 's/ens160/eth0/g' /etc/sysconfig/network-scripts/ifcfg-eth0
ens160
with your network interface name.
05- Reboot the host:
# reboot
04- When the reboot is done, run again the below command to check if the interface device naming successfully changed:
# nmcli con show NAME UUID TYPE DEVICE eth0 d0b9a4d5-0a50-4577-a115-41a1eceb943c ethernet eth0
Conclusion
You have successfully learned how to to disable the predictable naming rule and change your network device name from ens33 or ens160 to old name eth0.
You might want to check the following guides: