• 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. Tutorial on Linux Clustering (High Availability)
  2. How to enable text colour in vi similar to vim in CentOS/RHEL
  3. Spacewalk Installation Steps On CentOS/RHEL
  4. fdisk: command not found
  5. Linux OS Service ‘cups’
  6. System Log File /var/log/messages Is Getting Deleted or Trimmed Automatically (CentOS/RHEL)
  7. macof: command not found
  8. CentOS / RHEL 6 : How to limit memory resources for a specific user using cgroups
  9. apt-cache Command Examples
  10. CentOS / RHEL : Managing password ageing for users using chage (with practical Examples)

You May Also Like

Primary Sidebar

Recent Posts

  • powertop Command Examples in Linux
  • powertop: command not found
  • powerstat: command not found
  • powerstat Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright