centos7 change network card name

Install centos7 in the virtual machine and allocate two network cards. After the installation is complete, use the ip addrcommand to check the network cards and find that the network card names are ens33 and ens34, which are not in line with the usual usage habits. I want to change the network card names to eth0 and eth1. The specific operation steps are as follows.

1. Modify the network card configuration file

Enter the network card configuration file directory:

cd /etc/sysconfig/network-scripts/

Modify the name of the network card configuration file, it is recommended to back it up first

cp ifcfg-ens33 ifcfg-ens33.bak

nv ifcfg-ens33 ifcfg-eth0

Edit the ifcfg-ens33 file

vim ifcfg-ens33

Modify the NAME field and the DEVICE field

NAME=ens33change toNAME=eth0

DEVICE=ens33change toDEVICE=eth0

The operation of the network card ens34 is the same as above.

2. Modify the bootloader grub and reload

Add the following information to the GRUB_CMDLINE_LINUX item:

net.ifnames=0 biosdevname=0 net.ifnames=1 biosdevname=1 net.ifnames=2 biosdevname=2

After the addition is completed, it is as follows:

GRUB_TERMINAL_OUTPUT="console"GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb quiet"

Reload:

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

3. Restart the system

reboot

After restarting, execute the ip addrcommand to find that the network card names have been changed to eth0 and eth1

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324975917&siteId=291194637