Changing the Ethernet adapters name from ens or enp0s to eth
Hey there As discussed I would like to add the first post of this year as many of my students were also asking about it. Since RHEL7/CENTOS7 there has been a little confusion with the names of ethernet adapter. So here we go to learn how to make them simple eth.
From RHEL/CENTOS 7 it’s been observed that the naming convention of the Ethernet adapter are not same as it used to be in RHEL/CENTOS 6 or lower versions.
Previously in RHEL/CENTOS6 or lower versions, it used to be eth0, eth1 eth2 respectively which was very simple to understand. But, since RHEL/CENTOS7, 8 versions these names differs from Ethernet adapter types to models and even in different virtualization it uses different names. For example ens0, 1 or enp0s3 enp0s8 or sometimes eno112344.
This might create a confusion especially when you want to automate your work through different automation tools or even with a simple shell scripting.
To neutralize it back to simple eth names, let’s use the following steps
- Check the present name of the adapters that are connected
- Also we can check whether these names are getting changed during boot by using dmesg command
observe it says the default name is eth0 which is getting changed to enp0s3 during boot.
- To change the name back to default eth, update /etc/default/grub file by adding “net.ifnames=0”
[root@mlinux50 ~]# vim /etc/default/grub
BEFORE EDITING GRUB_CMDLINE_LINUX=”crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet”
AFTER EDITING GRUB_CMDLINE_LINUX=”crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap net.ifnames=0 rhgb quiet” |
- Re-create the grub config file to update with the changes we made in previous step
[root@mlinux50 ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file … done |
- Now then we have change the grub config file, let’s rename adapter configuration file to eth0
[root@mlinux50 network-scripts]# mv ifcfg-enp0s3 ifcfg-eth0 [root@mlinux50 network-scripts]# ls ifcfg-eth0 |
- Edit the adapter file and change the name to eth0 from enp0s3
Edit the above marked fields as shown below |
- Lastly reboot the system and confirm the adapter name after reboot
[root@mlinux50 network-scripts]# reboot |
- Post reboot veryify the change in names of the adapter
That’s how it needs to be done. Do comeback for more…
Prakash B
January 7, 2021 at 3:55 amSuperb Sir, Great Explanation 🙂
NITISH NIRANJAN
May 11, 2021 at 2:29 pmVery nice sir