一、网卡配置文件名称重命名为eth0
[root@root ~]# cd /etc/sysconfig/network-scripts/ [root@Jaking11 network-scripts]# ls ifcfg-ens33 ifdown-ppp ifup-eth ifup-sit ifcfg-lo ifdown-routes ifup-ippp ifup-Team ifdown ifdown-sit ifup-ipv6 ifup-TeamPort ifdown-bnep ifdown-Team ifup-isdn ifup-tunnel ifdown-eth ifdown-TeamPort ifup-plip ifup-wireless ifdown-ippp ifdown-tunnel ifup-plusb init.ipv6-global ifdown-ipv6 ifup ifup-post network-functions ifdown-isdn ifup-aliases ifup-ppp network-functions-ipv6 ifdown-post ifup-bnep ifup-routes [root@root network-scripts]# mv ifcfg-ens33 ifcfg-eth0二、禁用网卡命名规则
此功能通过/etc/default/grub文件来控制,要禁用此功能,在文件中加入 "net.ifnames=0 biosdevname=0"
[root@rootnetwork-scripts]# vim /etc/default/grub GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)" GRUB_DEFAULT=saved GRUB_DISABLE_SUBMENU=true GRUB_TERMINAL_OUTPUT="console" GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet net.ifnames=0 biosdevname=0" GRUB_DISABLE_RECOVERY="true"三、添加udev网卡规则
在/etc/udev/rules.d目录中创建一个网卡规则70-persistent-net.rules文件,在文件中写入以下参数:
SUBSYSTEM=="net",ACTION=="add",DRIVERS=="?*",ATTR{address}=="需要修改名称的网卡MAC地址",ATTR{type}=="1" ,KERNEL=="eth*",NAME="eth0"
参考配置:
[root@root rules.d]# vim 70-persistent-net.rules SUBSYSTEM=="net",ACTION=="add",DRIVERS=="?*",ATTR{address}=="00:50:56:29:0e:ae", ATTR{type}=="1" ,KERNEL=="eth*",NAME="eth0"执行grub2-mkconfig -o /boot/grub2/grub.cfg命令生成更新grub配置参数
[root@root rules.d]# grub2-mkconfig -o /boot/grub2/grub.cfg 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-fe49b659ccb940fa8d260a5897c0b08a Found initrd image: /boot/initramfs-0-rescue-fe49b659ccb940fa8d260a5897c0b08a.img done
重启Linux系统后验证网卡名称是否更改成功