[CentOS8] to modify the name of the network card eth0

  • View the current physical card information
# dmesg | grep eth
[    4.829146] vmxnet3 0000:03:00.0 eth0: NIC Link is Up 10000 Mbps
[    5.671853] vmxnet3 0000:03:00.0 ens160: renamed from eth0

We need to change eth0 ens160

  • View the current connection information
# nmcli connection show
NAME    UUID                                  TYPE      DEVICE
ens160  46f3176f-23ac-4af8-b9fe-08d3c668ba81  ethernet  ens160
  • New eth0 connection
# nmcli connection add type ethernet con-name eth0 ifname ens160
# nmcli connection show
NAME    UUID                                  TYPE      DEVICE
ens160  46f3176f-23ac-4af8-b9fe-08d3c668ba81  ethernet  ens160
eth0    55e201dc-0f9e-44c7-b6ae-da09370e3718  ethernet  --
  • Delete ens160 connection
# nmcli connection delete ens160
# nmcli connection show
NAME  UUID                                  TYPE      DEVICE
eth0  55e201dc-0f9e-44c7-b6ae-da09370e3718  ethernet  ens160
  • Modify the physical NIC name
# 查看配置文件
# ls /etc/sysconfig/network-scripts/
ifcfg-eth0
# 修改物理网卡名称
# sed -i 's/ens160/eth0/' /etc/sysconfig/network-scripts/ifcfg-eth0

  • Modify the Linux kernel configuration
# 备份配置文件
# \cp /etc/default/grub /etc/default/grub.bak
# 修改配置文件
# sed -i 's/rhgb/net.ifnames=0 &/' /etc/default/grub
# 生成启动文件
# grub2-mkconfig -o /boot/grub2/grub.cfg

  • Restart

END

Guess you like

Origin www.cnblogs.com/leoshi/p/12503088.html