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
It works… but what happen after a kernel update? line options are preserved?
LikeLike
I haven’t tried updating kernel, I would think it would preserve the changes. If not you need to reload networking stack so you can update it before doing so.
LikeLike
Kernel updates can possible overwrite grub file but in this case older version is saved…typically I havent seen this though
LikeLike
thank you so much.
Nice, easy and works 🙂
LikeLike
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
LikeLike
Yeah UEFI is still work.in-progress but thanks for suggestion hopefully UEFI is supported with Satellite 6.3.
LikeLike
On UEFI-based machines, use
grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
LikeLike
Works great! Saved me from ‘confusing network device naming’. Thanks!
LikeLike