[root@localhost ~]# ifconfig eth0 eth0: error fetching interface information: Device not found
奇怪的是 /etc/sysconfig/network-scripts/ 下的設定檔明明都是 eth0,卻抓不到裝置。
[root@localhost network-scripts]# mii-tool eth1: negotiated 100baseTx-FD, link ok
實體網卡其實存在,只是被核心命名為 eth1。
[root@localhost network-scripts]# ifconfig eth1 # 確實看得到 eth1
[root@localhost network-scripts]# mv ifcfg-eth0 ifcfg-eth1 [root@localhost network-scripts]# vi ifcfg-eth1
DEVICE=eth1 ONBOOT=yes TYPE=Ethernet BOOTPROTO=static IPADDR=192.168.xx.40 NETMASK=255.255.255.0 GATEWAY=192.168.xx.254
接著進入 networking 目錄,把 devices 與 profiles 底下引用的裝置名稱也一併改為 ifcfg-eth1:
[root@localhost ~]# cd /etc/sysconfig/networking/ [root@localhost networking]# ls devices profiles
[root@localhost devices]# /etc/rc.d/init.d/network restart
各介面依序關閉再拉起,全部 OK。
[root@localhost devices]# ping www.baidu.com PING www.a.shifen.com (220.181.111.148) 56(84) bytes of data. 64 bytes from 220.181.111.148: icmp_seq=1 ttl=52 time=33.1 ms 64 bytes from 220.181.111.148: icmp_seq=2 ttl=52 time=33.3 ms
網路恢復正常。
一開始判斷是驅動問題,lsmod 顯示載入的是 e1000e,於是建立 /etc/modprobe.d/modprobe.conf 寫入 alias,無效。
dmesg 的開機訊息顯示 e1000: eth1 NIC Link is Up 1000 Mbps Full Duplex,核心確實只認到 eth1。
後來又在 /lib/modules/2.6.32-71.el6.i686/modules.alias 中加入 alias eth0 e1000e,仍然無效,最後只能讓 eth1 取代 eth0。
根因通常是 udev 網路裝置命名規則的殘留紀錄(/etc/udev/rules.d/70-persistent-net.rules)把原網卡 MAC 綁到了 eth0,硬體更換或虛擬機克隆後便會錯位。清掉該檔中的舊條目再重啟,eth0 就能回來。
本文出自「有志者事竟成!」部落格,請務必保留此出處 https://zh888.blog.51cto.com/1684752/775447