如何修改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
相關文章
相關標籤/搜索