CentOS7系统更改网卡名为eth0

时间:2022-06-30 12:39:32

centOS7系统更改网卡名为eth0

1、编辑grub参数

[root@localhost ~]# vim /etc/sysconfig/grub

2、在GRUB_CMDLINE_LINUX行中添加以下红色部分参数(双引号一定要加)

GRUB_CMDLINE_LINUX="crashkernel=auto "net.ifnames=0 biosdevname=0" rhgb quiet"

3、重新生成grub配置文件

[root@localhost ~]# grub2-mkconfig /boot/grub2/grub.cfg
Generating grub configuration file ...
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

4、重启系统

[root@localhost ~]# reboot

此时运行ip addr 可以看到eth0

[root@localhost ~]# ip a
: lo: <LOOPBACK,UP,LOWER_UP> mtu qdisc noqueue state UNKNOWN
link/loopback ::::: brd :::::
inet 127.0.0.1/ scope host lo
valid_lft forever preferred_lft forever
inet6 ::/ scope host
valid_lft forever preferred_lft forever
: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu qdisc pfifo_fast state UP qlen
link/ether :0c::7d::5e brd ff:ff:ff:ff:ff:ff
inet 192.168.43.43/ brd 192.168.43.255 scope global noprefixroute dynamic eth0
valid_lft 3257sec preferred_lft 3257sec
inet6 fe80::caaa:d49f:54d3:32cd/ scope link noprefixroute
valid_lft forever preferred_lft forever
: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu qdisc noqueue state DOWN
link/ether :::6e:c8:cc brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/ brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
: virbr0-nic: <BROADCAST,MULTICAST> mtu qdisc pfifo_fast master virbr0 state DOWN qlen
link/ether :::6e:c8:cc brd ff:ff:ff:ff:ff:ff

5、在网卡参数配置文件中修改网卡名

[root@localhost ~]#cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# mv ifcfg-ens33 ifcfg-eth0
[root@localhost network-scripts]# vim ifcfg-eth0 

修改文件中的NAME和DEVICE为eth0。其余参数不变。最后重启网络服务。

NAME=eth0
DEVICE=eth0
[root@localhost ~]# systemctl restart network.service

完成

CentOS7系统更改网卡名为eth0