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

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • 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 Change Password Of An LXC Container User Account
  2. Beginners guide to vi editor (command line reference)
  3. showmount Command Examples in Linux
  4. How To Use distro-sync Option With dnf To Upgrade OS (CentOS/RHEL 8)
  5. Audit rules to log reboot command executions in CentOS/RHEL
  6. CentOS / RHEL 7 : GRUB2 configuration file /boot/grub2/grub.cfg explained
  7. How Files/Directories in /tmp gets Removed Automatically in CentOS/RHEL 5,6
  8. Linux OS Service ‘network’
  9. Starting udev: udevd inotify_init failed: too many open files
  10. Linux Interview Questions – Basic File and Directory Permissions

You May Also Like

Primary Sidebar

Recent Posts

  • What are different Oracle Database Vault Roles
  • Unable to export realm protected table using data pump
  • Beginners Guide to Oracle Database Vault
  • How to Disable IPv6 on Ubuntu 18.04 Bionic Beaver Linux
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary