Sunday 24 November 2019

How to Rename Network Interface Name on CentOS 8



In CentOS 7 and CentOS 8, a new NIC naming scheme is the predictable naming rule is adopted by default like ens192, enp3s0, eth0 and so on. To disable the predictable naming rule pass "net.ifnames=0" and biosdevname=0” kernel parameter during boot.
This article describes How to Rename Network Interface Name on CentOS 8.

[root@linuxcnf ~]# ip a
………………….
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:83:e3:fa brd ff:ff:ff:ff:ff:ff
    inet 192.168.43.168/24 brd 192.168.43.255 scope global dynamic noprefixroute enp0s3
       valid_lft 3525sec preferred_lft 3525sec
………………….
[root@linuxcnf ~]#

Step 1. Change in Grub Configuration: Edit the default grub configuration file /etc/default/grub and add parameters net.ifnames=0 biosdevname=0 GRUB_CMDLINE_LINUX as shown below:

[root@linuxcnf ~]# vi /etc/default/grub
……………………..
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"
……………………..
[root@linuxcnf ~]#

Step 2. Rebuild Grub Configuration: Run the following command to rebuild GRUB configuration with updated parameters as below:

[root@linuxcnf ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
done
[root@linuxcnf ~]#

Step 3. Change in Interface Configuration: Run the following commands to rename network interface’s configuration file from existing name i.e. ifcfg-enp0s3 to ifcfg-eth0 and update name of interface name and device name as shown below for eth0:

[root@linuxcnf ~]# mv /etc/sysconfig/network-scripts/ifcfg-enp0s3 /etc/sysconfig/network-scripts/ifcfg-eth0
[root@linuxcnf ~]#

[root@linuxcnf ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
NAME="eth0"
………………….
DEVICE="eth0"
………………….
[root@linuxcnf ~]#

Step 4. Rebooting Machine: Finally, reboot the machine to reflect the changes:

[root@linuxcnf ~]# reboot

Step 5. Validate the Changes: After reboot the machine, run the following to verify the changes:

[root@linuxcnf ~]# ip a
…………………….
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:83:e3:fa brd ff:ff:ff:ff:ff:ff
    inet 192.168.43.168/24 brd 192.168.43.255 scope global dynamic noprefixroute eth0
       valid_lft 3579sec preferred_lft 3579sec
……………………
[root@linuxcnf ~]#

Done!!! Interface consistent and predictable device naming is disabled.

No comments:

Post a Comment