kavin

Linux下解决Device eth0 does not seem to be present

kavin linux 2018-05-07 2646浏览 0

 我们经常会遇到linux的系统更换硬盘到其他机器,或者克隆虚拟机时网卡不能启动报错的情况,

用ifconfig命令不能看到我们的网卡信息,具体报错如下图:

Linux下解决Device eth0 does not seem to be present

为什么会造成这样的情况呢?

因为centos系统做好后,网卡的配置文件会把网卡的mac地址记录在配置文件中,

更换硬盘或者更克隆系统的时候,配置文件跟过来的是上个机器的mac地址信息,

所以会造成重启网卡不成功,报错,看不到网卡信息的情况!

如何解决这类问题呢!

具体解决方法如下:



首先,打开/etc/udev/rules.d/70-persistent-net.rules内容如下面例子所示:


# vi /etc/udev/rules.d/70-persistent-net.rules

# This file was automatically generated by the /lib/udev/write_net_rules

# program, run by the persistent-net-generator.rules rules file.

#

# You can modify it, as long as you keep each rule on a single

# line, and change only the value of the NAME= key.

# PCI device 0x1022:0x2000 (pcnet32)

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:8f:89:97",

ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x1022:0x2000 (pcnet32)

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:50:bd:17",

ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"


这时需要记录下,eth1网卡的mac地址00:0c:29:50:bd:17 

接下来,打开/etc/sysconfig/network-scripts/ifcfg-eth0 

# vi /etc/sysconfig/network-scripts/ifcfg-eth0

 将 DEVICE="eth0"  改成  DEVICE="eth1"  ,

将 HWADDR="00:0c:29:8f:89:97" 改成上面的mac地址  HWADDR="00:0c:29:50:bd:17"

 最后,重启网络

 # service network restart

或者

 # /etc/init.d/network restart

这时发现重启网卡可以启动了

问题解决


发表评论