Monday, May 25, 2015

Rename network interfaces in RHEL 7 x86

Setting interface 'eth0':
This procedure disables "consistent network device naming" and renames interfaces in RHEL7.

# 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
 

Append in the end of line an argument 'net.ifnames=0' in the section 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"

Regenarate grub.cfg:
# grub2-mkconfig -o /boot/grub2/grub.cfg

And then update the names of the network device name in the configuration files (/etc/network-scripts/ifcfg-*) as an example:

# mv /etc/sysconfig/network-scripts/ifcfg-eno1 /etc/sysconfig/network-scripts/ifcfg-eth0
# vi /etc/sysconfig/network-scripts/ifcfg-eth0

TYPE=Ethernet
BOOTPROTO=static
NAME=eth0
DEVICE=eth0
ONBOOT=yes
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPADDR0=192.168.0.1
NETMASK0=255.255.255.0
HWADDR=51:54:00:88:d9:f7
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes

Reboot the host:

# shutdown -r now

Reference:

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Networking_Guide/ch-Consistent_Network_Device_Naming.html


No comments:

Post a Comment