How to change network interface name to eth0 on CentOS 8 / RHEL 8

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Hello, friends. In this post, you will learn How to change network interface name to eth0 on CentOS 8 and RHEL 8

When on a Linux system, you show the name of the network interfaces, usually, the Ethernet connection is shown with eth0 but if you do it on CentOS, you will get an ens33 or an enp0s3 and how to reverse this? Well, let’s go for it.

First, the cause

Why does this happen? The reason is that CentOS and RHEL derivatives use a naming system for network interfaces. This causes them to be renamed at boot time.

To confirm that they have been renamed, you can first check the network interfaces

ip a

And then

dmesg | grep -i eth

To get an on-screen output similar to this

1.- eth0 interface
1.- eth0 interface

Don’t allow CentOS to Change network interface name

To make CentOS abandon this behavior, you need to edit the file /etc/default/grub.

sudo vim /etc/default/grub

And inside the file (be careful when editing) modify this line

GRUB_CMDLINE_LINUX="crashkernel=auto resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet"

For this one:

GRUB_CMDLINE_LINUX="crashkernel=auto resume=/dev/mapper/cl-swap rd.lvm.lv=cl/root rd.lvm.lv=cl/swap net.ifnames=0 rhgb quiet"

They are very similar. The difference is in net.ifnames=0 which prevents renaming.

Save the changes and close the editor.

Apply the changes by generating a new Grub configuration file.

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

Change network interface name

Now it remains to apply and change the name to eth0. To achieve this, rename the Ethernet interface configuration file.

sudo mv /etc/sysconfig/network-scripts/ifcfg-enp0s3 /etc/sysconfig/network-scripts/ifcfg-eth0

Now edit the file

sudo vim /etc/sysconfig/network-scripts/ifcfg-eth0

And modify the values of NAME and DEVICE.

NAME="enp0s3"
DEVICE="enp0s3"

For these

NAME="eth0"
DEVICE="eth0"

Save the changes and close the editor.

Restart the system and that is it.

ip a
Change network interface name
Change network interface name

Conclusion

So, this trick although simple can help you to customize and make the system more yours. So, you have also touched a little on the boot, and it is always good to learn from it.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Angelo
Angelo
I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook