Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> 關於Linux

CentOS 6.0 網卡 eth0 消失問題排查與修復

1. 現象

[root@localhost ~]# ifconfig eth0
eth0: error fetching interface information: Device not found

奇怪的是 /etc/sysconfig/network-scripts/ 下的設定檔明明都是 eth0,卻抓不到裝置。

2. 確認實體網卡狀態

[root@localhost network-scripts]# mii-tool
eth1: negotiated 100baseTx-FD, link ok

實體網卡其實存在,只是被核心命名為 eth1。

[root@localhost network-scripts]# ifconfig eth1     # 確實看得到 eth1

3. 把設定檔改成 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

4. 重啟網路並驗證

[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

Copyright © Linux教程網 All Rights Reserved