Change the NIC name of CentOS 7 to eth0 format

Source: Internet
Author: User

Change the NIC name of CentOS 7 to eth0 format

The traditional naming methods for Nic devices in Linux are eth0, eth1, and eth2. CentOS7 provides different naming rules, which are allocated by default based on the firmware, topology, and location information. The advantage of this is that the name is fully automatic and predictable. The disadvantage is that it is more difficult to read than eth0 and wlan0, such as ens33.

I. Naming rule policies

Rule 1:

For on-board Device Names that combine the index numbers provided by the firmware or BIOS, if the information from the firmware or BIOS is readable, it is usually named, such as eno1. Otherwise, rule 2 is used.

Rule 2:

Name the index number of the PCI-E Hot Plug Port provided by the merging firmware or BIOS, such as ens1, used if the information is readable, otherwise rule 3 is used.

Rule 3:

Name the physical location of the merged hardware interface, such as enp2s0. If it is available, name it. If it fails, go to solution 5.

Rule 4:

The MAC address of the naming merge interface, such as enx78e7d1ea46da, is not used by default unless you choose to use this scheme.

Rule 5:

If all the schemes fail, use a style similar to eth0.

2. Nic name characters

1. Meaning of the first two characters

En Ethernet Ethernetwl Wireless LAN WLANww wireless WAN WWAN

2. 3rd characters are selected based on the device type

o<index>           on-board device index numbers<slot>            hotplug slot index numberx<MAC>             MAC addressp<bus>s<slot>      PCI geographical locationp<bus>s<slot>      USB port number chain

3. Change the NIC name style to ethx

If you are not used to the new naming rules, you can revert to naming in the traditional way, edit the grub file, add two variables, and then regenerate the grub configuration file using the grub2-mkconfig.

1. Edit the grub configuration file

Vim/etc/sysconfig/grub # is actually a soft connection to/etc/default/grub # Add two parameters to the GRUB_CMDLINE_LINUX variable. The specific content is as follows (bold ): GRUB_CMDLINE_LINUX = "crashkernel = auto rd. lvm. lv = cl/root rd. lvm. lv = cl/swap net. ifnames = 0 biosdevname = 0 rhgb quiet"

2. regenerate the grub configuration file.

grub2-mkconfig -o /boot/grub2/grub.cfg

Then restart the Linux operating system. The ip addr shows that the NIC name has changed to eth0.

3. Modify the NIC configuration file

The original Nic configuration file name is called the ifcfg-ens33, here you need to modify the format of ethx, and adjust the NIC configuration file.

Mv/etc/sysconfig/network-scripts/ifcfg-ens33/etc/sysconfig/network-scripts/ifcfg-eth0 # modify the following contents of the ifcfg-eth0 file (others remain unchanged) NAME = eth0DEVICE = eth0 [root @ localhost ~] # Systemctl restart network. service # restart the network service

Note: It is best to delete the ifcfg-ens33 file, otherwise an error will be reported when you restart the network service.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.