RHEL 7 / CentOS 7 use classic eth0 style device naming for network adapters – Flatpack Linux【转载】

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 ?

HOW 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.

Then we can safely edit the grub configuration file

The config file will look similar to the following

The line that starts “GRUB_CMDLINE_LINUX” needs to have some extra paramters added.

The extra parameters are

So the final file looks like

ADD THIS TO THE BOOT CONFIGURATION

If you are using a UEFI system then rebuild grub with this command

Otherwise use the following

RESTART THE MACHINE

Now we will restart the host, and the new naming scheme will take effect on reboot.

MOVE 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.

For 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.

Rename the old interface configuration file to new scheme

Update the contents of the configuration file to use the new scheme

RESTART THE NETWORK SERVICE

Finally restart the network service so the changes take effect.

Now the interface can be seen with the correct IP address.

 

 

来源: RHEL 7 / CentOS 7 use classic eth0 style device naming for network adapters – Flatpack Linux

发表评论

电子邮件地址不会被公开。 必填项已用*标注