现象:
一台克隆生成的centos,启动后使用ifconfig查看网络信息,发现只有lo而没有任何可用网卡.
使用ifup eth0后报vmware device eth0 does not seem to be present delaying initialization
大概意识是找不到eth0这个网络设备
使用
ls /sys/class/net
查看物理网卡信息返回结果如下:
eth1 lo
原因:
很多Linux distribution使用udev动态管理设备文件,并根据设备的信息对其进行持久化命名。例如在
解决方法:
编辑如下文件
/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 0x15ad:0x07b0 (vmxnet3) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:bc:00:45", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x15ad:0x07b0 (vmxnet3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:bc:00:46", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# 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 0x15ad:0x07b0 (vmxnet3) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:bc:00:45", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x15ad:0x07b0 (vmxnet3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:bc:00:46", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
注释掉eth0的那个段落,然后将eth1的修改为eth0
修改网卡配置文件
/etc/sysconfig/network-scripts/ifcfg-eth0
把mac地址修改为eth1的地址
HWADDR字段
重启后生效
当然,如果你还什么东西都没装,没有在什么配置文件中指定过eth0字段的话.直接cp或者mv ifcfg-eth0 ifcfg-eth1也是可以的.