VMware中克隆虚拟机出现eth0改变为eth1情况

解决如下:

查看复制虚拟机网卡信息如下:

 1 root@jcfx-2 ~]# ifconfig
 2 eth1      Link encap:Ethernet  HWaddr 00:0C:29:CC:32:63  
 3           inet addr:192.168.72.11  Bcast:192.168.72.255  Mask:255.255.255.0
 4           inet6 addr: fe80::20c:29ff:fecc:3263/64 Scope:Link
 5           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
 6           RX packets:17551 errors:0 dropped:0 overruns:0 frame:0
 7           TX packets:166 errors:0 dropped:0 overruns:0 carrier:0
 8           collisions:0 txqueuelen:1000 
 9           RX bytes:1303129 (1.2 MiB)  TX bytes:63288 (61.8 KiB)
10 lo        Link encap:Local Loopback  
11           inet addr:127.0.0.1  Mask:255.0.0.0
12           inet6 addr: ::1/128 Scope:Host
13           UP LOOPBACK RUNNING  MTU:16436  Metric:1
14           RX packets:8 errors:0 dropped:0 overruns:0 frame:0
15           TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
16           collisions:0 txqueuelen:0 
17           RX bytes:584 (584.0 b)  TX bytes:584 (584.0 b)

具体需求是将eth1修改为eth0:

为什么eth0会变成eth1?

Linux distribution使用udev动态管理设备文件,并根据设备的信息对其进行持久化命名。udev会在系统引导的过程中识别网卡,将mac地址和网卡名称对应起来记录在udev的规则脚本中。而对于新的虚拟机,VMware会自动为虚拟机的网卡生成MAC地址,当你克隆或者重装虚拟机软件时,由于你使用的是以前系统虚拟硬盘的信息,而该系统中已经有eth0的信息,对于这个新的网卡,udev会自动将其命名为eth1(累加的原则),所以在你的系统启动后,你使用ifconfig看到的网卡名为eth1;

RedHat中,udev记录网络规则的脚本为:/etc/udev/rules.d/70-persistent-net.rules

1 [root@jcfx-2 ~]# more /etc/udev/rules.d/70-persistent-net.rules 
2 # This file was automatically generated by the /lib/udev/write_net_rules
3 # program, run by the persistent-net-generator.rules rules file.
4 # You can modify it, as long as you keep each rule on a single
5 # line, and change only the value of the NAME= key.
6 # PCI device 0x15ad:0x07b0 (vmxnet3)
7 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:a0:25:f7", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
8 # PCI device 0x15ad:0x07b0 (vmxnet3)
9 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:cc:32:63", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
 1 解决如下:
 2 将70-persistent-net.rules脚本中多出来的eth1信息注销,并且修改原有的eth0的MAC地址信息,该信息与eth1的MAC信息保持一致,或者修改为别的MAC地址;
 3 修改如下:
 4 [root@jcfx-2 ~]# more /etc/udev/rules.d/70-persistent-net.rules 
 5 # This file was automatically generated by the /lib/udev/write_net_rules
 6 # program, run by the persistent-net-generator.rules rules file.
 7 # You can modify it, as long as you keep each rule on a single
 8 # line, and change only the value of the NAME= key.
 9 # PCI device 0x15ad:0x07b0 (vmxnet3)
10 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:cc:32:63", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
11 # PCI device 0x15ad:0x07b0 (vmxnet3)
12 #SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:cc:32:63", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
13 最后重启服务器:
14 reboot

 

转载于:https://www.cnblogs.com/qlwang/p/8018789.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值