故障情况

ifconfig...没有看到eth0.。然后重启网卡又报下面错误。

service network restart
Shutting down loopback insterface:                                                                                                     [  OK  ]
Bringing up loopback insterface:                                                                                                          [  OK  ]
Bringing up interface eth0:  Device eth0 does not seem to be present,delaying initialization.                    [FAILED]

解决办法

首先,打开/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 0x8086:0x1004 (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:e0:0e:0c", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

接下来,打开/etc/sysconfig/network-scripts/ifcfg-eth0
内容如下所示:

DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.0.188
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
DNS1=192.168.0.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
NAME="System eth0"
以上两个文件的NAME(eth0)和address(mac)地址需要想同;如/etc/sysconfig/network-scripts/ifcfg-eth0设置HWADDR配置,需要设置为该主机的mac地址。
所以:

方法一:
删除/etc/udev/rules.d/70-persistent-net.rules文件,重启系统,自动初始化一条网卡配置,且ATTR{address}值为主机mac地址。(暴力方式)

方法二:
修改/etc/sysconfig/network-scripts/ifcfg-eth0和/etc/udev/rules.d/70-persistent-net.rules文件相关配置。

如果是虚拟机,记得设置的mac地址需要跟以上两配置文件的mac地址相同。

好了,该问题解决了。