Rename network interfaces in RHEL 7

Overview

RHEL 7 has a new feature called “consistent network device naming“. The idea is to regardless of NIC hardware have consistent interface names and not names which can be change based on underlying hardware. Traditionally interface names were enumerated as eth[0,1,2…]. In many environments administrators would like to use names that refer to the purpose of the network interface especially when a host bridges into various networks e.g. mgmt[0,1,2…], storage[0,1,2…] or client[0,1,2…]. This post we show how to change interface names in RHEL 7 and CentOS 7.

Change Interface Names

The below procedure disables “consistent network device naming” and renames interfaces.

  • vi /etc/default/grub

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=”$(sed ‘s, release .*$,,g’ /etc/system-release)”
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT=”console”
GRUB_CMDLINE_LINUX=”rd.lvm.lv=rootvg/usrlv rd.lvm.lv=rootvg/swaplv crashkernel=auto vconsole.keymap=us rd.lvm.lv=rootvg/rootlv vconsole.font=latarcyrheb-sun16 rhgb quiet”
GRUB_DISABLE_RECOVERY=”true”

Change the GRUB_CMDLINE_LINUX and regenerate grub.cfg:

  • GRUB_CMDLINE_LINUX=”rd.lvm.lv=rootvg/usrlv rd.lvm.lv=rootvg/swaplv crashkernel=auto vconsole.keymap=us rd.lvm.lv=rootvg/rootlv vconsole.font=latarcyrheb-sun16 rhgb quiet net.ifnames=0 biosdevname=0
  • grub2-mkconfig -o /boot/grub2/grub.cfg

Update the names of the network scripts

  • mv /etc/sysconfig/network-scripts/ifcfg-eno00012224 /etc/sysconfig/network-scripts/ifcfg-mgmt0

TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=mgmt0
UUID=ecfe9674-774e-4c5a-a3a6-a84336306b62
ONBOOT=yes
IPADDR0=10.10.10.90
PREFIX0=24
GATEWAY0=10.10.10.1
DNS1=10.10.10.5
DNS2=10.10.10.6
DOMAIN=mydomain.com
HWADDR=00:50:56:B4:6D:57
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
DEVICE=mgmt0

Reboot system with reconfiguration

  • shutdown -r now

(c) 2014 Keith Tenzer

6 thoughts on “Rename network interfaces in RHEL 7

  1. This doesn’t work for UEFI, havn’t found a working solution, but I did find a nice “one-liner” by NerdVittles.

    sed -i ‘s|quiet|quiet net.ifnames=0 biosdevdame=0|’ /etc/default/grub
    grub2-mkconfig -o /boot/grub2/grub.cfg

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s