Grub configuration to disable consistent network device naming in OEL 7

Preamble

Starting with Red Hat Enterprise Linux 7 and so Oracle Enterprise Linux 7 (and maybe on many other linux distributions, at least Centos 7 for sure) the network interface names have been moved to something a little bit different from traditional eth[0,1,2,..]:

[root@server3 ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:47:54:07 brd ff:ff:ff:ff:ff:ff
    inet 192.168.56.102/24 brd 192.168.56.255 scope global enp0s3
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe47:5407/64 scope link
       valid_lft forever preferred_lft forever
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:fc:21:55 brd ff:ff:ff:ff:ff:ff
    inet 10.70.101.94/24 brd 10.70.101.255 scope global dynamic enp0s8
       valid_lft 3572sec preferred_lft 3572sec
    inet6 fe80::a00:27ff:fefc:2155/64 scope link
       valid_lft forever preferred_lft forever

The reason for this is clear from Red Hat official documentation:

In Red Hat Enterprise Linux 7, udev supports a number of different naming schemes. The default is to assign fixed names based on firmware, topology, and location information. This has the advantage that the names are fully automatic, fully predictable, that they stay fixed even if hardware is added or removed (no re-enumeration takes place), and that broken hardware can be replaced seamlessly. The disadvantage is that they are sometimes harder to read than the eth0 or wlan0 names traditionally used. For example: enp5s0.

How to come back to legacy situation ? You might want to do this not only because bad habits die hard but simply because you are configuring a cluster of servers (RAC, NoSQL, …) and want to be sure that the interconnect interface is called eth0 on all your nodes…

Grub configuration

This blog post has been written with a virtual machine running Oracle Linux Server release 7.3 and having two network interfaces: one for interconnect and one for internet access.

grub01
grub01

Edit /etc/default/grub file and at the end of GRUB_CMDLINE_LINUX variable value add:

net.ifnames=0 biosdevname=0

Examples:

  • GRUB_CMDLINE_LINUX=”crashkernel=auto rd.lvm.lv=vg00/lvol00 rd.lvm.lv=vg00/lvol01 rhgb quiet numa=off transparent_hugepage=never net.ifnames=0 biosdevname=0″
  • GRUB_CMDLINE_LINUX=”crashkernel=auto rd.lvm.lv=vg00/lvol00 rd.lvm.lv=vg00/lvol01 rhgb quiet net.ifnames=0 biosdevname=0″

Rebuild Grub configuration:

[root@server3 ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.1.12-61.1.25.el7uek.x86_64
Found initrd image: /boot/initramfs-4.1.12-61.1.25.el7uek.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-514.6.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-514.6.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-7e6fb04dc02343d0a54dccc3940ad366
Found initrd image: /boot/initramfs-0-rescue-7e6fb04dc02343d0a54dccc3940ad366.img
done

Copy network configuration interface files to new name:

[root@server3 grub2]# cd /etc/sysconfig/network-scripts/
[root@server3 network-scripts]# cp ifcfg-enp0s3 ifcfg-eth0
[root@server3 network-scripts]# cp ifcfg-enp0s8 ifcfg-eth1

Change values of NAME and DEVICE in both files:

[root@server3 network-scripts]# cat ifcfg-eth0
HWADDR=08:00:27:DC:FB:92
TYPE=Ethernet
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV4_DNS_PRIORITY=100
IPV6INIT=yes
IPV6_AUTOCONF=no
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
IPV6_DNS_PRIORITY=100
NAME=eth0
UUID=eefd48d5-7810-4848-a1ce-9040938fb455
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.56.103
PREFIX=24
[root@server3 network-scripts]# cat ifcfg-eth1
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eth1
UUID=6b145311-798e-4927-8876-18d02570f386
DEVICE=eth1
ONBOOT=yes
PEERDNS=yes
PEERROUTES=yes

Disable network manager:

[root@server3 ~]# systemctl disable NetworkManager
Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.

Reboot server:

[root@server3 ~]# reboot

You should see something like:

[root@server3 ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:47:54:07 brd ff:ff:ff:ff:ff:ff
    inet 192.168.56.102/24 brd 192.168.56.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe47:5407/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 08:00:27:fc:21:55 brd ff:ff:ff:ff:ff:ff
    inet 10.70.101.94/24 brd 10.70.101.255 scope global dynamic eth1
       valid_lft 604794sec preferred_lft 604794sec
    inet6 fe80::a00:27ff:fefc:2155/64 scope link
       valid_lft forever preferred_lft forever

As we have modified the default grub configuration the change is resisting to a Kernel upgrade !! Welcome to old legacy network naming !

With the drawback that cool network tools are not working anymore:

[root@server3 ~]# nmcli
Error: NetworkManager is not running.
[root@server3 ~]# nmtui
NetworkManager is not running.

References

About Post Author

This entry was posted in Linux and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>