WHY WAS IT CHANGED ?
Red Hat Enterprise Linux 7 introduced a new scheme for naming network devices called “Consistent Device Naming”. It’s called Consistent Device Naming because previously the name of the devices [eth0,eth1,eth2] was completely dependant upon the order the kernel detected them as it booted. In certain circumstances, such as adding new devices to an existing system, the naming scheme could become unreliable.
FURTHER READING
The official Red Hat 7 Documentation on consistent device naming can be found here.
WHAT DOES THE NEW SCHEME LOOK LIKE ?
12345 # ip link show1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULTlink/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:002: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000link/ether 00:0c:29:89:1b:2e brd ff:ff:ff:ff:ff:ffHOW DO I CHANGE IT BACK TO ETH[0-9] STYLE NAMING ?
In summary we need to
- Add extra parameters to the kernel configuration
- Add this to the boot configuration
- Restart the machine
- Move the existing interfaces to the new scheme
- Restart the network service
ADD EXTRA PARAMETERS TO THE KERNEL CONFIGURATION
Modify the grub bootloader to pass some extra parameters to the kernel at boot time. The kernel will then use these options to decide which naming scheme to use.
First we backup and edit the grub configuration file.
1 # cp /etc/default/grub /etc/default/grub.bakThen we can safely edit the grub configuration file
1 # vim /etc/default/grubThe config file will look similar to the following
1234567 GRUB_TIMEOUT=5GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"GRUB_DEFAULT=savedGRUB_DISABLE_SUBMENU=trueGRUB_TERMINAL_OUTPUT="console"GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet "GRUB_DISABLE_RECOVERY="true"The line that starts “GRUB_CMDLINE_LINUX” needs to have some extra paramters added.
The extra parameters are
1 biosdevname=0 net.ifnames=0So the final file looks like
1234567 GRUB_TIMEOUT=5GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"GRUB_DEFAULT=savedGRUB_DISABLE_SUBMENU=trueGRUB_TERMINAL_OUTPUT="console"GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet biosdevname=0 net.ifnames=0 "GRUB_DISABLE_RECOVERY="true"ADD THIS TO THE BOOT CONFIGURATION
If you are using a UEFI system then rebuild grub with this command
1 # grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfgOtherwise use the following
1234567 # grub2-mkconfig -o /boot/grub2/grub.cfgGenerating grub configuration file ...Found linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.imgFound linux image: /boot/vmlinuz-0-rescue-3c913eca0eab4ebcb6da402e03553776Found initrd image: /boot/initramfs-0-rescue-3c913eca0eab4ebcb6da402e03553776.imgdoneRESTART THE MACHINE
Now we will restart the host, and the new naming scheme will take effect on reboot.
1 # shutdown -r nowMOVE THE EXISTING INTERFACES TO THE NEW SCHEME
It’s possible you may now need to reconfigure your network interface.
Here you can see the network interface is up, however there is no IP information associated with the new device name.
12345 # ip link1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULTlink/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:002: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000link/ether 00:0c:29:89:1b:2e brd ff:ff:ff:ff:ff:ffFor this example we will assume i’m not using NetworkManager. Therefore I’ll be editing the network configuration files in /etc/sysconfig/network-scripts directly.
Change into the network scripts directory.
1 # cd /etc/sysconfig/network-scripts/Rename the old interface configuration file to new scheme
1 # mv ifcfg-eno16777736 ifcfg-eth0Update the contents of the configuration file to use the new scheme
1 # sed -i 's/eno16777736/eth0/' ifcfg-eth0RESTART THE NETWORK SERVICE
Finally restart the network service so the changes take effect.
1 # systemctl restart networkNow the interface can be seen with the correct IP address.
12345678910111213 # ip addr1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWNlink/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope hostvalid_lft forever preferred_lft forever2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000link/ether 00:0c:29:89:1b:2e brd ff:ff:ff:ff:ff:ffinet 192.168.100.3/24 brd 192.168.100.255 scope global eth0valid_lft forever preferred_lft foreverinet6 fe80::20c:29ff:fe89:1b2e/64 scope linkvalid_lft forever preferred_lft forever
来源: RHEL 7 / CentOS 7 use classic eth0 style device naming for network adapters – Flatpack Linux