Monday, March 19, 2018

Restore standard naming of network interfaces on Red Hat enterprise linux 7

Disabling consistent network device naming

To disable The consistent network device naming feature and create your own manual ma,ing scheme ,for example eth0,internet0 or lan0. Follow the below steps so that all network device names will be eth followed by an integer.

  • Log in as root, or as a user with superuser privileges.
  • 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 at the end and between the delimiter characters (").         .
      GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet net.ifnames=0 biosdevname=0"                                                                         
    4. Save the file, and then close the text editor 
  • 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.


  • 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

Found linux image: /boot/vmlinuz-3.10.0-229.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-229.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-09377eb6cd424f3e802d04d64a5da531
Found initrd image: /boot/initramfs-0-rescue-09377eb6cd424f3e802d04d64a5da531.img
done

  • 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
      ifcfg-enp0s3
      ifcfg-enp0s8
      ifcfg-enp0s9
      
      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-eno16777736, use the mv command rename it to ifcfg-eth0
      # mv ifcfg-enp0s3 ifcfg-eth0 
      # mv ifcfg-enp0s8 ifcfg-eth1 
      # mv ifcfg-enp0s9 ifcfg-eth2
    4. change the values of the NAME and DEVICE variables inside the file to eth0/1/2..
    5. # vi ifcfg-eth0 
      TYPE=Ethernet
      BOOTPROTO=none
      DEFROUTE=yes
      IPV4_FAILURE_FATAL=no
      IPV6INIT=yes
      IPV6_AUTOCONF=yes
      IPV6_DEFROUTE=yes
      IPV6_FAILURE_FATAL=no
      NAME=enp0s3   ---> change to eth0
      UUID=54828c5b-65be-42b1-8b4e-07627c67487f
      DEVICE=enp0s3 ---> change to eth0
      ONBOOT=yes
      IPADDR=192.168.78.51
      PREFIX=24
      DNS1=192.168.78.51
      DNS2=192.168.78.52
      DOMAIN=evilcorp.com
      IPV6_PEERDNS=yes
      IPV6_PEERROUTES=yes
      IPV6_PRIVACY=no
      
      
      

  • Reboot the host.
    You can confirme the configuration by runing network manager user interface (nmtui) or
    the following commands : 
    # nmcli dev
    DEVICE  TYPE      STATE      CONNECTION
    eth0    ethernet  connected  eth0
    eth1    ethernet  connected  eth1
    eth2    ethernet  connected  eth2
    lo      loopback  unmanaged  --
    
    # nmcli con 
    NAME  UUID                                  TYPE            DEVICE
    eth0  54828c5b-65be-42b1-8b4e-07627c67487f  802-3-ethernet  eth0
    eth2  04583597-c715-4ac5-954e-13dc748991a9  802-3-ethernet  eth2
    eth1  2418c04d-4291-48e6-95d1-3de63cd58d6a  802-3-ethernet  eth1

No comments:

Post a Comment