CentOS7使用了“一致性网络命名方法”,这里举例,将网卡名截断为前5个字符,如eno16777736改为eth1。
1.复制原网卡配置并改为ifcfg-eth1
cp /etc/sysconfig/network-scripts/ifcfg-eno16777736 /etc/sysconfig/network-scripts/ifcfg-eth1
2.修改配置内容:
NAME 改为eth1
DEVICE 也改为eth1
删除UUID
删除HWADDR
vi /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后
改为【GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap net.ifnames=0 biosdevname=0 rhgb quiet"】
grub2-mkconfig -o /boot/grub2/grub.cfg
修改/etc/udev/rules.d/70-persistent-net.rules,没有该文件则新建文件
vi /etc/udev/rules.d/70-persistent-net.rules
添加如下内容,有几个网卡就写几行:
ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="1", ATTR{address}=="?*00:02:c9:03:00:31:78:f2", NAME="eth0" ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="1", ATTR{address}=="?*00:02:c9:03:00:31:78:f2", NAME="eth1"
注意MAC地址与NAME相匹配(可以用ip addr查看)
chkconfig NetworkManager off #
chkconfig network on #
service NetworkManager stop #
service network restart #
#或者直接重启
reboot
nmcli connection
如果NetworkManager服务关闭,此命令不可用
原文:https://www.cnblogs.com/GaZeon/p/12616767.html