复制或克隆虚拟机后无 eth0 或 eth0 变eth1 ( 同理eth[x] 变 eth[x+1] )解决方法如下:
在虚拟机里直接删除掉文件 /etc/udev/rules.d/70-persistent-net.rules
原因呢,是 udev 在作怪,关于udev的原理,参考:http://blog.csdn.net/absurd/article/details/1587938
这里简单说明下,看看 /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:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:3a:2e:3f", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:ed:21:78", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:9a:24:1d", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:f8:03:ea", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3"
~
可见我系统目前有4个网络接口:
eth0 MAC地址:08:00:27:3a:2e:3f
eth1 MAC地址:08:00:27:ed:21:78
eth2 MAC地址:08:00:27:9a:24:1d
eth3 MAC地址:08:00:27:f8:03:ea
而我虚拟机提供的网卡的MAC地址只有 08:00:27:f8:03:ea ,所以我在虚拟机里是无法使用 eth0,eth1,eth2
要想使用eth0 而不是虚拟机移动后的 eth1 等等,可以在 /etc/udev/rules.d/70-persistent-net.rules 里把eth0接口绑定的MAC地址改成当前虚拟机软件(VBox,或VMware...)提供给虚拟机的MAC地址,当然直接删除 /etc/udev/rules.d/70-persistent-net.rules 让系统重新绑定更省事 !