Disable consistent network device naming in RHEL7

Latest response

In RHEL6, I simply had to kickstart with 'biosdevname=0' to disable this and fall back to ethX interface naming. In RHEL7, I understand that I need to use net.ifnames=0 in order to do this, but it doesn't retain after installation. I'm looking for the best way to automate disabling consistent network device naming during installation (Kickstart). Any thoughts?

Also, Page 117 in the RHEL7 Networking Guide incorrectly tells me I need to modify /etc/grub.conf.

Responses

Ok, both biosdevname=0 net.ifnames=0 are required at install time to disable consistent network device naming (which isn't really consistent at all on VMWare).

It looks Josh is satisfied with what he worked out, but I still want to give a more complete response:

You have two options (as described in the new RHEL 7 Networking Guide) to disable the new naming scheme:

  • Run once: ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules

OR

  • Run once: echo 'GRUB_CMDLINE_LINUX="net.ifnames=0"' >>/etc/default/grub

Note that the biosdevname package is not installed by default, so unless it gets installed, you don't need to add biosdevname=0 as a kernel argument.

Be careful with the second option. YOu may overwrite system's default parameters.

The file to be edited is /etc/sysconfig/grub and the var GRUB_CMDLINE_LINUX needs to be modified to have the previous options plus "biosdevname=0 net.ifnames=0"

Hello,

ls -l /etc/sysconfig/grub shows there is a symlink: /etc/sysconfig/grub -> /etc/default/grub So editing /etc/default/grub is what is shown in the System Administrator's Guide, for reasons of reliability, here: Customizing GRUB 2 Menu, Editing a Menu Entry

Thank you EDIT: Fix link above and add this as its preferred Making Persistent Changes to a GRUB 2 Menu Using the grubby Tool

Noted!. Thanks for the info.

I am kickstarting a 7.1 build in VMWare Fusion (same happens in ESX) and the "ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules" is apparently ignored. It works using "net.ifnames=0 biosdevname=0" in the append section of the kickstart file though. Why wouldn't the "ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules" work?

Hello Josh

Thank you for reporting this.

I'll investigate and update the guide as necessary.

Thank you

Hello,

I will change the Networking Guide to say "Add the following line to the /etc/default/grub file"

BTW, quote from the Networking Guide "unless the system is a Dell system, or biosdevname is explicitly enabled as described in Section 9.4.2, “Enabling and Disabling the Feature”, the systemd naming scheme will take precedence. "

thank you

Hey Josh - could you give a short explanation or use-case of why you prefer legacy naming for your interfaces? I'm just curious and wondering what other teams have run in to regarding issues. I'm in a Dell shop and I have found the biosdevname to be helpful (since we don't have a consistent hardware layout as well).
Thanks!

Mainly because when using VMWare, the biosdevname makes no sense. It's not consistent at all.

Ah - brilliant! That makes total sense.

Thanks for the insight.

I found this very confusing and documentation misleading as well. On this page: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Networking_Guide/ch-Consistent_Network_Device_Naming.html it sounds like the way to get back to the kernel naming was to set the biosdevname=1 kernel cmndline option. It turns out you have to set biosdevname=0 and net.ifnames=0 (as above), thought the symlink to /dev/null (also above) does work as well.

We also have a large VM environment where the new-hotness in network interface naming is highly unpredictable, and the old-n-busted kernel naming scheme is actually 100% predictable.

Hello

I am sorry you found the documentation misleading. Note that biosdevname is not enabled by default except on Dell systems, so setting those options on the command line should not be required in your VM case.

I have just read through Disabling Consistent Network Device Naming and I realize now that there needs to be a note to rebuild the grub file. The line "For more information about GRUB2 see Red Hat Enterprise Linux 7 System Administrator's Guide" is not strong enough.

I will send a patch to the guide maintainer.

How do I get this to work with anaconda / kickstart?

I added --append="net.ifnames=0" to the bootloader entry in kickstart and this gets it added to grub, but I still end up with ifcfg-ens192 on the initial build.

Thanks!

Ah ... I just needed to pass net.ifnames=0 on anaconda bootup. "Kernel Options" in RedHat Satellite.

Nice. This the parameter net.ifnames=0 will be reflected in the installed system (RHEL 7.1 +) . See Which boot time parameters from the kickstart file will be reflected in the grub.cfg file on RHEL 7.1

I did this as well but my interface still shows ifcg-enxxxxxxx.

I've added it to the bootloader option as well. Is there anything else you had to do?

Ok. So it starts eth0 but enxxxxxxx is still configured. I had to rename the file and update the name within it, then restart the interface. Is there a way to have it write to eth0?

This is causing us a big headache with auto provisioning viaSatellite kickstarting, it looks like the NIC naming format usingthe grub bootloader method doesn't take effect until the final boot, meaning the network provisioning script writes out old naming formats in network scripts.

Writing a post execute renaming script seems to be the easiest way forward but makes more advanced configurations like dual nic routing far more painful than it needs to be.

Maybe 10 years ago this change would have been useful in the physical space, but in a virtual world I don't see how this is useful.

You need to customize the Kickstart PXEBoot templates in Sat6

Could you share an example of customizing Kickstart PXEBoot templates in Sat6?

This is my EL7 PXE Kickstart PXE template in Foreman/Sat6:

<%#
kind: PXELinux
name: Community Kickstart PXE
oses:
- RedHat 7
%>
default linux
label linux
kernel <%= @kernel %>
<% if @host.operatingsystem.name == "Fedora" and @host.operatingsystem.major.to_i > 16 -%>
append initrd=<%= @initrd %> ks=<%= foreman_url("provision")%> ks.device=bootif network ks.sendmac biosdevname=0 net.ifnames=0
<% else -%>
append initrd=<%= @initrd %> ks=<%= foreman_url("provision")%> ksdevice=bootif network kssendmac biosdevname=0 net.ifnames=0
<% end -%>
IPAPPEND 2

Good Day, I am deploying a RHEL 7.2 VM and having a little trouble getting the ethx names to show up. I appended the following in my kickstart

bootloader --location=mbr --append="net.ifnames=0 biosdevname=0"

After the VM is deployed, the only network connection to show up is the loopback adapter. I know there are benefits for using the new naming on Physical servers, but I would like to use the old name for our Virtual Machines.

What am I missing?

I figured it out. The line for the grub during boot to the automation, I added net.ifnames=0 and that fixed the issue.

Can you tell please what exactly and where did you add to fix that ?

I am trying to prepare RHEL 7.2 installation ISO using kickstart and I have:

bootloader --location=mbr --append="net.ifnames=0"

but after boot and installation process I still get

/etc/sysconfig/network-scripts/ifcfg-eno*

file and not /ifcfg-eth0 which is what I want (I get eth0 device though ...) In addition my the /etc/sysconfig/network-scripts/ifcfg-eno doesn't have the settings I used in bootloader line from kickstart (why ?)

I ran into the same problem, but i also want to rename eth0 to eth1 and eth1 to eth0. After trial and error i have ended up with just solely a udev rule and removing all other suggestions from grub config. udev rule(based on example i found on internet):

cat /etc/udev/rules.d/70-persistent-net.rules

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:XX:XX:XX", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:XX:XX:XY", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

On the XX/XY fil lin the correct mac-adresses and create the ifcfg-eth* files.

To make sure it is really persistent i also ran: grubby --update-kernel=ALL reboot dracut -f -v reboot

Works for me, my solution is very different to all solution I see on internet, i do not know why i just only need a udev-rule and nothing else. I wonder if just adding the udev-rule would work for others too?

Here is what I have done to preserve the net.ifnames=0 biosdevname=0 values after kickstart. I have a post install that runs at the tail end of the process, and as part of this, I run the following code snippet:

  # THIS IS FOR RHEL 7: Change ethernet interface to work as eth0
  sed -i 's/rhgb quiet/net.ifnames=0 biosdevname=0 ipv6.disable=1/' /etc/default/grub
  grub2-mkconfig -o /boot/grub2/grub.cfg
  if [ -d /boot/efi/EFI/redhat ]; then
    grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
  fi

As you can see, it modifies the /etc/default/grub file and then reconfigures grub by running grub2-mkconfig. The added bonus here is to support UEFI boot as well.

Hi Gustavo, the script is a very much help to be able to append the "net.ifnames=0 biosdevname=0 ipv6.disable=1" in the boot loader, however the naming convention is still enoxxxx. it requires to delete the existing enoxxxx then the eth0 will appear after reboot. I am currently using spacewalk 2.6 and included in the post script. Is there anyway to make the eth0 consistent after the installation without the need of removing the interface and rebooting the system? Thanks in advance

Hi Gustavo, I have try a work around by removing the default enxxxx in the /etc/sysconfig/network-scripts/ifcfg-enxx. So far after the server reboot, the NIC are now eth0. Thanks for your script, big help to my deployment. rm -rf /etc/sysconfig/network-scripts/ifcfg-en* sed -i 's/rhgb quiet/net.ifnames=0 biosdevname=0 ipv6.disable=1/' /etc/default/grub grub2-mkconfig -o /boot/grub2/grub.cfg if [ -d /boot/efi/EFI/redhat ]; then grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg fi

Rommel , sorry for the late reply. I have actually a combination of things going. I create a boot ISO that already disables consistent network device naming, so the machine gets kickstarted already using ethX like NICs. That way I do not need to deal with removing other device related files.

Hello,

I am curious if anyone was able to get the names changed on their nics back to the eth0, eth1....naming scheme as I was? If so did you have problems with traffic through the nics after the name changes? I have my names on my two nics as I want eth0 and eth1 with the corresponding IP address assigned as they're supposed to be. That being said I am not able to ping the server now or pass traffic as I need. The mac address match in the ifcfg-ethX files as well. (RHEL 7.3)

Any thoughts or input would be great.

Thanks,

Jake

I've had the same question as Jake. I know we all need to learn the "new way" of doing things, but in the virt world these crazy NIC device names in RHEL 7 seem crazy.

Thanks for any input.

There are only a few situations where persistent ethX naming works on RHEL 7:

  • any system with only one NIC
  • KVM (libvirt only, not RHV or OpenStack) VM with virtio NICs

For anything else, you really should be using systemd or biosdevname persistent names, or your own manual naming scheme which doesn't collide with system names such as "netX" or "lanX".

This is described further at:

I was able to pass biosdevname=0 and net.ifnames=0 to kernel command and let my system come up with eth* naming conventions. but I am trying to set up some udev rules based on pci numbers. I tried adding the udev rules by using KERNELS variable set to pci number . does that works in RHEL 7?

I see udevadm info of the interface has the pci numbers has ID_PATH AND ID_PATH_TAG populated with the pci number of the device , is there anyway I can manipulate my requirement using this ? Thanks

Persistent naming based on ethX names does not work at all in RHEL 7. We recommend you don't do this.

In RHEL6, the combination of udev rules (file /etc/udev/rules.d/70-persistent-net.rules containing both MAC address and Name=XXX) can be combined with same entries in ifcfg-(XXX) file for perfect control over any changes. Why is this discounted?

I get that adding or replacing NICs can cause re-ordering, but MAC and Device name alignment should provide 100% control.

What is the preferred method to set a particular ethernet device to an arbitrary name in RHEL7?

Ex: Say I want to name the backup NIC to be called /dev/backnet.

I need a process that is consistent with On-Prem, Colocation and Cloud (Azure, AWS etc). Thanks!

Ran across this after dealing with interface names that were too long in a home lab.

with USB Ethernet devices the name is 12+ characters long. So, when I tried to add a vlan to the interface the name became longer than 15 characters and gets rejected by RHV.

I'm actually using this tip from stackoverflow

https://serverfault.com/questions/616060/location-of-70-persistent-net-rules-in-centos-7/938970#938970 mkdir /etc/systemd/network vim /etc/systemd/network/10-lan0.link [Match] MACAddress=00:50:56:b7:65:2b

[Link] Name=lan0