Naming of virtio-net interfaces is not consistent in RHEL 7
Environment
- Red Hat Enterprise Linux 7
- KVM or RHEV/RHV virtual machine guest using:
- One or more paravirtual NIC type using
virtio-netdriver - One or more other emulated NIC type such as Intel
e1000or Realtekrtl8139
- One or more paravirtual NIC type using
Issue
- The name of a virtio-net interface is seen to be different or unstable after a reboot.
- virtio and e1000 or rtl8139 NICs change device names from
ethtoensnames randomly or unpredictably.
Resolution
Enable persistent network device naming for virtio devices:
-
Edit the
/etc/default/grubfile -
Add
net.ifnames=1to the end of theGRUB_CMDLINE_LINUXparameter -
Rebuild the bootloader config with
grub2-mkconfig > /boot/grub2/grub.cfg -
Reboot the system.
-
Once rebooted, inspect device names and MAC addresses with
ip addr -
If there is a mismatch where a kernel device name does not match the
/etc/sysconfig/network-scripts/ifcfg-*file parametersDEVICEorNAME, then correct theifcfg-*files so that all three (kernel device,DEVICEparameter,NAMEparameter) are the same. -
Reboot again so the desired naming and interface configuration applies to each interface.
Workaround
Ensure that every interface presented to the guest is of the same type, and never use disparate network device types in the same system.
This is done by changing the virtual device type in the libvirt or RHV management interface.
Ideally, all interfaces should be virtio-net in a KVM/RHV VM.
Root Cause
-
The option to apply systemd persistent naming to virtio-devices was added in RHEL 7.2 with Bug 1259015 - persistent interface names for virtio interfaces, which introduced the following patch:
-
This behaviour is not applied by default, but is opt-in, requiring
net.ifnames=1on the GRUB kernel boot line. -
The most common cause of unstable names for virtio interfaces is a result of having a mix of virtio interfaces and some other interface type such as
e1000orrtl8139within the same guest. Standardizing on one interface type for all guest interfaces can also avoid the issue without needing persistent naming.
-
Booting any RHEL 7 system, guest or not, with the kernel command line parameter
net.ifnames=0set is known to cause naming issues. Please see the following article for more information:
Diagnostic Steps
-
The type of NIC can be verified from within the guest with the
ethtoolcommand. It will list the name of the driver the interface uses:[root@rhel_guest ~]# ethtool -i eth0 driver: virtio_net version: 1.0.0 firmware-version: expansion-rom-version: bus-info: 0000:00:03.0 supports-statistics: no supports-test: no supports-eeprom-access: no supports-register-dump: no supports-priv-flags: no -
From the hypervisor side, the type of NIC presented to the guest can be verified from
virt-managerand by usingvirshto review a guest's XML definition.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.