centos6.3/centos7.4虚拟机之网卡出现ifconfig eth1 eth1: error fetching interface information: Device not found,eth0: error fetching interface information: Device not found问题之解决

jackxiang 2012-11-12 10:14 | |
背景:因为虚拟机经从一台电脑拷贝到另一台电脑时,出现了网卡问题,于是把ifcfg-eth0 -->ifcfg-eth1.后启动Ok,但是,在开机会出现:eth0: error fetching interface information: Device not found。root 用户su xiangdong时会出现:ifconfig eth1 ,eth1: error fetching interface information: Device not found
解决办法:
1.刚开始运行ifconfig eth0发现网卡不见了。
[root@localhost ~]# ifconfig eth0
eth0: error fetching interface information: Device not found //但是network-scripts里的配置文件全部是eth0的,为什么获取不到也不知道为什么?
处理解决方法只能用eth1替换eth0了,自己创建modprobe.conf文件里面alias eth0 e1000e但是不能识别。

2.[root@localhost network-scripts]# mii-tool //查看网卡连接状态
   eth1: negotiated 100baseTx-FD, link ok

3.[root@localhost network-scripts]# ifconfig eth1//能发现eth1网卡

4.[root@localhost network-scripts]# mv ifcfg-eth0 ifcfg-eth1//修改eth0为eth1

5.[root@localhost network-scripts]# vi ifcfg-eth1
DEVICE=eth1//把eth1修改为eth0
ONBOOT=yes//启动激活
TYPE=Ethernet
BOOTPROTO=static//静态ip
IPADDR=192.168.xx.40
NETMASK=255.255.255.0
GATEWAY=192.168.xx.254

6.[root@localhost ~]# cd /etc/sysconfig/networking/ //进入networking目录
[root@localhost networking]# ls//里面有两个文件把里面的设备修改为ifcfg-eth1即可。
devices  profiles

7.[root@localhost devices]# /etc/rc.d/init.d/network restart //重新启动network守护进程。
Shutting down interface eth1:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth1:                                [  OK  sss]

8.[root@localhost devices]# ping www.baidu.com //最后ping 百度通了
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
64 bytes from 220.181.111.148: icmp_seq=3 ttl=52 time=33.4 ms

遇到的问题:
刚开始因为以为驱动问题,lsmod看了一下加载的驱动为e1000e,所以在 /etc/modprobe.d/里添加了modprobe.conf文件可是还是不行。
dmesg查看启动信息查看网卡信息为e1000: eth1 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
后来查看/lib/modules/2.6.32-71.el6.i686/modules.alias 添加alias eth0 e1000e 还是不行,只能用eth1代替eth0


本质上是阿里云经典的Eth0/Eth1迁移到VPC网,只有Eth0网卡导致的,可能上面的内容还搞不定?得向这个方向寻找:
cat /etc/udev/rules.d/70-persistent-net.rules
# PCI device 0x10ec:0x8139 (8139too)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:e0:4c:90:06:83", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x10ec:0x8168 (r8169)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:e0:4c:10:cd:ab", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

TrevorH wrote:
Look in /etc/udev/rules.d for a file called something with persistent-net-rules in it. Edit that and look at the contents - it probably contains lines for both eth0 and eth1. You should remove the lines that refer to eth0 and can also change eth1 to eth0 afterwards if you'd prefer to have eth0 rather than eth1 on your system (though it doesn't really matter what it's called so long as it works). Save that and then look in /etc/sysconfig/network-scripts for the various ifcfg-eth* files there. You'll want to remove the one for eth0. If you renamed eth1 to eth0 then you need to rename ifcfg-eth1 to ifcfg-eth0 and edit its contents as it also contains the string 'eth1' inside it.
You can verify if the MAC address found on the device is same as that present in the /etc/udev/rules.d/*-persistent-net.rules

作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/5749/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!


最后编辑: jackxiang 编辑于2018-3-22 23:40
评论列表
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]