Disabling consistent network device naming

The consistent network device naming feature can create device names that are too long for use with virtual IPs. This step disables the feature so that all network device names are eth followed by an integer.
  1. Log in as root, or as a user with superuser privileges.
  2. Edit the GRUB 2 general settings file.
    1. Create a backup copy of the settings file.
      cp /etc/default/grub /etc/default/grub.bak
    2. Open /etc/default/grub with a text editor.
    3. Add kernel boot arguments to the value of the GRUB_CMDLINE_LINUX variable.
      The arguments to add are biosdevname=0 and net.ifnames=0. Make sure the arguments are between the delimiter characters (").
    4. Save the file, and then close the text editor.
  3. Determine whether the host is configured for UEFI or legacy boot mode.
    find /boot -maxdepth 1 -type d
    • If the output includes /boot/efi, the host is configured for UEFI boot mode.
    • If the output does not include /boot/efi, the host is configured for legacy boot mode.
  4. Recreate the GRUB 2 boot configuration file.
    For UEFI boot mode:
    grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
    For legacy boot mode:
    grub2-mkconfig -o /boot/grub2/grub.cfg
  5. Create an override for the default rules policy of the dynamic device management daemon.
    ln -s /dev/null /etc/udev/rules.d/80-net-name-slot.rules
  6. Change network device configurations.
    1. Change directory to /etc/sysconfig/network-scripts.
      cd /etc/sysconfig/network-scripts
    2. List the network device configuration files.
      ls ifcfg-* | grep -v ifcfg-lo
      The ifcfg-lo file is excluded because it does not need to be changed.
    3. Rename and edit device files.
      For example, if you have a device file named ifcfg-enp0s3, use the mv command rename it to ifcfg-eth0, and then change the values of the NAME and DEVICE variables inside the file to eth0.
  7. Update the default route.
    1. Display the current default route.
      ip route show | head -n 1
      Example result, showing device enp0s3 and gateway host 198.51.100.1:
      default via 198.51.100.1 dev enp0s3  proto static  metric 100
    2. Update the network device.
      Replace Device-Name with the name of the device to update:
      ip link set Device-Name down ; \
        ip link set Device-Name name eth0 ; ip link set eth0 up
      To maintain your terminal session, perform the preceding commands as shown.
    3. Update the default route.
      Replace Gateway-Address with the IP address of the gateway host:
      ip route replace default via Gateway-Address dev eth0
  8. Reboot the host.