CentOS 7.2更改网卡名称

添加net.ifnames=0 biosdevname=0

[root@localhost ~]# vi /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"
[root@localhost ~]#

更新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
[root@localhost ~]#

添加设备规则配置文件

修改/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"
[root@localhost ~]#

注意MAC地址与NAME相匹配(可以用ip addr查看)

重启

[root@localhost ~]# reboot

  

  

posted @ 2019-05-12 14:09  xiangwb  阅读(69)  评论(0编辑  收藏  举报