这种情况一般出现在克隆的KVM虚拟机,目前还不知道出现这种状况具体原因,问题的具体表现就是无法上网,重启网卡的时候会在bring up interface那步出错,提示“正忙稍后再试”。输入ifconfig -a显示的是eth1,但是网卡配置目录下/etc/system/network-scripts/的配置文件却是eth0,由于这种不对称才会产生这种情况。
另一种可能是第一次启动的网卡,网卡配置文件里必须要有网卡的硬件地址,否则也会无法启动网卡。
解决方法1:查看 输入ifconfig -a 命令后显示的是哪个网卡,例如eth1,然后在/etc/system/network-scripts/目录下新建一个eth1的网卡配置文件。
解决方法2: vi /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"
如上黑色加粗字体为关键部分,将eth0那句删掉,将“eth1”改为“eth0”,使用 service network restart重启网卡/虚拟机即可。如果还不得,进入/etc/system/network-scripts/eth0 查看是否有网卡硬件地址,如果有则删除后再次重启网卡/虚拟机。