复制或克隆虚拟机后无eth0或eth0变eth1

复制或克隆虚拟机后无 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 让系统重新绑定更省事 !



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值