1. 程式人生 > >centos7 網卡識別為eth0 eth1

centos7 網卡識別為eth0 eth1

ade grub配置 測試 sub div distrib sco ble spa

使網卡識別為 eth0

方法一。安裝系統是,net.ifnames=0 biosdevname=0

方法二。(沒有測試):

修改網卡配置文件中的 DEVICE= 參數的關於 eth0

[[email protected] ~]# cd /etc/sysconfig/network-scripts/
[[email protected] network-scripts]# vi ifcfg-eno16777728
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=eno16777728 UUID=8a3eade8-005c-46df-81f2-6e2598457bac #DEVICE=eno16777728 DEVICE=eth0 ONBOOT=yes

網卡配置文件名稱改為 ifcfg-eth0

[[email protected] network-scripts]# mv ifcfg-eno16777728 ifcfg-eth0

因 CentOS7 采用 grub2 引導,還需要對 grub2 進行修改,編輯 /etc/default/grub 配置文件,在 GRUB_CMDLINE_LINUX 這個參數後面加入 net.ifnames=0 biosdevname=0

[[email protected] network-scripts]# vi /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="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet net.ifnames=0 biosdevname=0" GRUB_DISABLE_RECOVERY="true"

用 grub2-mkconfig 命令重新生成GRUB配置並更新內核

[[email protected] network-scripts]# 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-4dd6b54f74c94bff9e92c61d669fc195
Found initrd image: /boot/initramfs-0-rescue-4dd6b54f74c94bff9e92c61d669fc195.img
done

重啟系統

reboot

重啟完成之後 驗證,ip addr 或者 ifconfig

centos7 網卡識別為eth0 eth1