• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to change the interface name in CentOS/RHEL 8 using prefixdevname

by admin

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
Note: The customized prefix name should not conflict with default or below prefix names used for NIC naming in CentOS/RHEL systems, i.e. eth, eno, ens, em.

Filed Under: CentOS/RHEL 8, Linux

Some more articles you might also be interested in …

  1. How to Restart Network Services in CentOS/RHEL 8
  2. CentOS / RHEL 7 : sysctl kernel parameter doesn’t take effect after reboot
  3. CentOS / RHE 7 : How to Prevent Users from Using the Last 10 Passwords
  4. How to debug systemd boot process in CentOS/RHEL 7 and 8
  5. How to create partitions inside loopback device
  6. How to merge 2 volume groups (VGs) into one using vgmerge in LVM
  7. How to view file size/details from ls command in Unix
  8. TIME_WAIT queue troubles
  9. ip Command Examples to Manage Networking in Linux
  10. Downgrading an rpm package to a lower version (using “rpm” command)

You May Also Like

Primary Sidebar

Recent Posts

  • JavaFX ComboBox: Set a value to the combo box
  • Nginx load balancing
  • nginx 504 gateway time-out
  • Images preview with ngx_http_image_filter_module

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright