Centos7.x中的网卡名称不再是eth0 可能是ens160…等等。 下面把网卡名称改为eth0
重命名网卡
1
2
|
[root@k8s-77-40 ~]# cd /etc/sysconfig/network-scripts/
[root@k8s-77-40 network-scripts]# mv ifcfg-ens160 ifcfg-eth0
|
编辑网卡配置
1
2
3
4
5
6
7
8
|
[root@k8s-77-40 network-scripts]# vim ifcfg-eth
...
NAME="eth0" #修改为eth0
UUID="b11c4f40-f2c4-483e-a692-4a60aab6bd9b"
DEVICE="eth0" #修改为eth0
ONBOOT="yes"
IPADDR="xxx.xxx.xxx.xxx"
...
|
修改grub文件
新增net.ifnames=0 biosdevname=0
1
2
3
4
|
[root@k8s-77-40 network-scripts]# vim /etc/sysconfig/grub
...
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet net.ifnames=0 biosdevname=0" #在最后添加net.ifnames=0 biosdevname=0
...
|
重新生成grub配置文件
1
2
3
4
5
6
7
|
[root@k8s-77-40 network-scripts]# grub2-mkconfig -o /boot/grub2/grub.cfg #重新生成grub配置并更新内核参数
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-957.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-957.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-03ba73cc59be45258e7c5a192171d79e
Found initrd image: /boot/initramfs-0-rescue-03ba73cc59be45258e7c5a192171d79e.img
done
|
新增udev规则
1
2
3
4
5
6
|
[root@k8s-77-40 network-scripts]# cd /etc/udev/rules.d/
[root@k8s-77-40 rules.d]# vim 70-persistent-ipoib.rules
...
#增加以下内容 ATTR{address}=="00:50:56:b2:48:15"为网卡的MAC地址,可以通过ifconfig查看获得
SUBSYSTEM=="net",ACTION=="add",DRIVERS=="?*",ATTR{address}=="00:50:56:b2:48:15",ATTR{type}=="1" ,KERNEL=="eth*",NAME="eth0"
...
|
重启系统查看
1
2
3
4
|
[root@k8s-77-40 rules.d]# reboot
[root@k8s-77-40 ~]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
...
|
修改网卡名称至此结束
Author
dylan
LastMod
2020-03-21
License
如需转载请注明文章作者和出处。谢谢!