最近参与群里的企业级linux综合实验项目的时候,需要大量的虚拟机来搭建实验环境,便使用了一台闲置的8G内存的hp145,安装了esxi4来部署虚拟机,为了方便,安装好一个RHEL6,制作成了OVF模板,添加了两块网卡。结果利用该OVF模板建立新的虚拟机后,网卡无法使用,ifconfig 只有lo的信息,没有添加的两个网卡的ip信息。经过一番查看,终于找到了原因,及相关的解决办法,记录如下:
具体错误信息,
/etc/init.d/network 后会出现
device eth0 does not seem to be present, delaying intitialization
device eth1 does not seem to be present, delaying intitialization
dmesg | grep eth
发现了如下内容
renamed network interface eth0 to eth2
renamed network interface eth1 to eth3
ls /etc/sysconfig/network-scripts/
发现只有
ifcfg-eth0 ifcfg-eth1 的配置文件
而且检查了eth0的配置文件 如下
DEVICE=”eth0″
NM_CONTROLLED=”yes”
ONBOOT=”yes”
BOOTPROTO=static
IPADDR=10.0.8.10
NETMASK=255.255.255.0
并没有任何异常
最后google了一番,出现该问题的时候涉及一个文件
/etc/udev/rules.d/70-persistent-net.rules
具体内容如下:
[root@rhellab ~]# more /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 0×8086:0x100f (e1000) (custom name provided by external tool)
SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR{address}==”00:50:56:94:66:7
1″, ATTR{type}==”1″, KERNEL==”eth*”, NAME=”eth0″
# PCI device 0×8086:0x100f (e1000) (custom name provided by external tool)
SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR{address}==”00:50:56:94:57:c
7″, ATTR{type}==”1″, KERNEL==”eth*”, NAME=”eth1″
# PCI device 0×8086:0x100f (e1000)
SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR{address}==”00:50:56:94:18:1
c”, ATTR{type}==”1″, KERNEL==”eth*”, NAME=”eth2″
# PCI device 0×8086:0x100f (e1000)
SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR{address}==”00:50:56:94:14:b
e”, ATTR{type}==”1″, KERNEL==”eth*”, NAME=”eth3″
看了这个文件以后,发现了问题的所在。也就想到了解决办法。
只要删掉# PCI device 0×8086:0x100f (e1000) 这四段内容,然后重启即可。