Centos7更改网卡名称Eth0

浏览次数:2794 关键词 ( 网卡  名称  )

安装完Centos7系统,网卡命名跟之前发生了变化,例如:eno16777736

就是看着不爽,也不会影响使用,只是个网卡名称而已。

 

1、先编辑网卡的配置文件将里面的NAME和DEVICE项修改为eth0

 

[plain] view plain copy    print?在CODE上查看代码片派生到我的代码片
  1. vim /etc/sysconfig/network-scripts/ifcfg-eno16777736   

 

 

2、重命名该配置文件。

 

[plain] view plain copy    print?在CODE上查看代码片派生到我的代码片
  1. [root@localhost yum.repos.d]#  cd /etc/sysconfig/network-scripts/  
  2. [root@localhost network-scripts]# mv ifcfg-eno16777736 ifcfg-eth0  

 

3、禁用该可预测命名规则。

对于这一点,你可以在启动时传递“net.ifnames=0 biosdevname=0 ”的内核参数。这是通过编辑/etc/default/grub并加入“net.ifnames=0 biosdevname=0 ”到GRUBCMDLINELINUX变量来实现的。

 

[plain] view plain copy    print?在CODE上查看代码片派生到我的代码片
  1. [root@localhost network-scripts]# vim /etc/default/grub   

 

 

4、运行命令grub2-mkconfig -o /boot/grub2/grub.cfg 来重新生成GRUB配置并更新内核参数。

 

[plain] view plain copy    print?在CODE上查看代码片派生到我的代码片
  1. [root@localhost network-scripts]# grub2-mkconfig -o /boot/grub2/grub.cfg   

 

 

5、重新启动机器,启动完之后网卡名称就变成了Eth0

 

[plain] view plain copy    print?在CODE上查看代码片派生到我的代码片
  1. [root@localhost network-scripts]# init 6  

 


6、重启完之后,验证!