如何修改CentOS7网卡名

1、关闭一致性网络设备命名法linux

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"

在GRUB_CMDLINE_LINUX中添加net.ifnames=0 biosdevname=0,文件内容变为以下:ios

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内核配置:centos

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

2、修改/etc/udev/rules.d/90-eno-fix.rules文件网络

若是文件不存在,则新建。ui

内容以下:spa

# This file was automatically generated on systemd update
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:3e:89:a4", NAME="eno-16777xxx"

将Name修改成eth0:code

# This file was automatically generated on systemd update
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:3e:89:a4", NAME="eth0"

若是有多个网卡,则会存在多条记录:blog

# This file was automatically generated on systemd update
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:3e:89:a4", NAME="eth0"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:3e:89:a6", NAME="eth1"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:3e:89:a8", NAME="eth2"

3、重启计算机it

reboot
相关文章
相关标签/搜索