CentOS 7 修改网卡名
配置
CentOS7使用了“一致性网络命名方法”,
1、更改网卡配置文件名
[root@localhost network-scripts]# vim ifcfg-ens33 TYPE=Ethernet BOOTPROTO=dhcp DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_PEERDNS=yes IPV6_PEERROUTES=yes IPV6_FAILURE_FATAL=no NAME=eth0 UUID=803d2d05-493b-489b-8201-1d3fc67878aa DEVICE=eth0 ONBOOT=yes
2、关闭“一致性网络设备命名法”
更改前
[root@localhost ~]# cat /etc/sysconfig/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" GRUB_DISABLE_RECOVERY="true" 添加net.ifnames=0 biosdevname=0
更改后
[root@localhost ~]# cat /etc/sysconfig/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 net.ifnames=0 biosdevname=0 rhgb quiet" GRUB_DISABLE_RECOVERY="true"
更新GRUB、内核配置
[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg Generating grub configuration file ... Found linux image: /boot/vmlinuz-3.10.0-327.el7.x86_64 Found initrd image: /boot/initramfs-3.10.0-327.el7.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-f034e6e19df748b7a27fad77b06e3179 Found initrd image: /boot/initramfs-0-rescue-f034e6e19df748b7a27fad77b06e3179.img done
3、添加设备规则配置文件
修改/etc/udev/rules.d/70-persistent-net.rules,没有该文件则新建文件
内容如下
[root@localhost ~]# cat /etc/udev/rules.d/70-persistent-net.rules SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:a3:b1:5c", ATTR{type}=="1", KERNEL=="eth*", NAME="eno16" SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:a3:b1:8e", ATTR{type}=="1", KERNEL=="eth*", NAME="eno10" SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:a3:b1:66", ATTR{type}=="1", KERNEL=="eth*", NAME="eno33" SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:a3:b1:70", ATTR{type}=="1", KERNEL=="eth*", NAME="eno50" SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:a3:b1:7a", ATTR{type}=="1", KERNEL=="eth*", NAME="eno67" SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:a3:b1:84", ATTR{type}=="1", KERNEL=="eth*", NAME="eno83"
注意MAC地址与NAME相匹配(可以用ip addr查看)
4、重启
[root@localhost ~]# reboot