This post will help to change the network interface name using prefixdevname utility in CentOS/RHEL 8 systems.
Installation and configuration
1. Install the required package using dnf utility:
# dnf install prefixdevname
2. Append the net.ifnames.prefix=[ABCD] using grubby command: (ABCD to replaced with own prefix, eg: net).
# grubby --update-kernel=$(grubby --default-kernel) --args="net.ifnames.prefix=net"
3. Reboot the system to take effect:
# reboot
4. After system rebooted, the new network interface name eg: net should be displayed in the output of below commands.
# ip link show # nmcli device status
Example
Before appending net.ifnames.prefix parameter
# cat /proc/cmdline BOOT_IMAGE=(hd0,msdos1)/vmlinuz-4.18.0-80.el8.x86_64 root=/dev/mapper/ol-root ro crashkernel=auto resume=/dev/mapper/ol-swap rd.lvm.lv=ol/root rd.lvm.lv=ol/swap rhgb quiet
# ip link show 1: lo:mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback brd 00:00:00:00:00:00 2: ens6: mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether brd ff:ff:ff:ff:ff:ff 3: virbr0: mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000 link/ether brd ff:ff:ff:ff:ff:ff 4: virbr0-nic: mtu 1500 qdisc fq_codel master virbr0 state DOWN mode DEFAULT group default qlen 1000 link/ether brd ff:ff:ff:ff:ff:ff
# nmcli device status
DEVICE TYPE STATE CONNECTION
ens6 ethernet connected Wired connection 1
virbr0 bridge connected virbr0
lo loopback unmanaged --
virbr0-nic tun unmanaged --
# ls -l /etc/systemd/network/ ls: cannot access '/etc/systemd/network/': No such file or directory
After appending net.ifnames.prefix=net parameter
# cat /proc/cmdline
BOOT_IMAGE=(hd0,msdos1)/vmlinuz-4.18.0-80.el8.x86_64 root=/dev/mapper/ol-root ro crashkernel=auto resume=/dev/mapper/ol-swap rd.lvm.lv=ol/root rd.lvm.lv=ol/swap rhgb quiet net.ifnames.prefix=net
# ls -l /etc/systemd/network/
total 4
-rw-r--r--. 1 root root 55 Aug 19 20:34 71-net-ifnames-prefix-net0.link
Above command shows that, created udev rules for the new name prefix.
# ip link show 1: lo:mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: net0: mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 56:6f:4c:a7:00:08 brd ff:ff:ff:ff:ff:ff 3: virbr0: mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000 link/ether 52:54:00:a3:48:05 brd ff:ff:ff:ff:ff:ff 4: virbr0-nic: mtu 1500 qdisc fq_codel master virbr0 state DOWN mode DEFAULT group default qlen 1000 link/ether 52:54:00:a3:48:05 brd ff:ff:ff:ff:ff:ff
# nmcli device status
DEVICE TYPE STATE CONNECTION
net0 ethernet connected Wired connection 1
virbr0 bridge connected virbr0
lo loopback unmanaged --
virbr0-nic tun unmanaged --
How to disable prefixdevname
1. Update the kernel command line parameter using grubby command:
# grubby --update-kernel=$(grubby --default-kernel) --remove-args="net.ifnames.prefix=net"
2. Remove all the created udev rules for prefixdevname, Before that take a backup of these configs files to different locations:
# rm -rvf /etc/systemd/network/-net*
3. Reboot the system to take effect the default prefix format.
# reboot