Sunday 6 March 2022

How to disable consistent network device naming in CentOS 8



This article describes How to disable consistent network device naming in CentOS 8.
 
[root@linuxcnf ~]# cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)
[root@linuxcnf ~]#
 
Current network adapter name:
 
[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:66:cc:f4 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.103/24 brd 192.168.1.255 scope global dynamic noprefixroute enp0s3
..................
[root@linuxcnf ~]#
 
Step 1. Grub Configuration: Insert the following line in grub configuration file /etc/default/grub:
 
[root@linuxcnf ~]# echo 'GRUB_CMDLINE_LINUX=" net.ifnames=0 biosdevname=0"' >>/etc/default/grub
 
Step 2. Rebuild Grub: Run the following command to rebuild the Grub configuration with the net ifnames parameters:
 
[root@linuxcnf ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
done
[root@linuxcnf ~]#
 
Step 3. Copy Network Configuration File: Run the below command to copy the network configuration file with matching the new interface name:
 
[root@linuxcnf ~]# mv /etc/sysconfig/network-scripts/ifcfg-enp0s3 /etc/sysconfig/network-scripts/ifcfg-eth0
 
Step 4. Change in Network Configuration File: Run the following command to edit the network interface configuration. Change the values of NAME and DEVICE from the old to the new interface name:
 
[root@linuxcnf ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
...............................
NAME=eth0
DEVICE=eth0
...............................
[root@linuxcnf ~]#
 
Save and close the file after changes.
 
Step 5. Machine Reboot and Validate: Reboot the machine to reflect the changes and run the below command to validate 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:66:cc:f4 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.103/24 brd 192.168.1.255 scope global dynamic noprefixroute eth0
..................
[root@linuxcnf ~]#
 
Done!!! Consistent network device naming disabled successfully on CentOS 8.

No comments:

Post a Comment