VM克隆後找不到eth0的問題解決
阿新 • • 發佈:2018-01-10
新的 net errors chang rules ask ifcfg-eth key tomat
第一步:編輯MAC地址,將
問題描述
使用VM WorkStation新建虛擬機A,查看IP信息,顯示結果:
[root@centos65x64 ~]# ifconfig -a eth0 Link encap:Ethernet HWaddr 00:0C:29:C7:E3:4C inet addr:192.168.188.131 Bcast:192.168.188.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fec7:e34c/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:120 errors:0 dropped:0 overruns:0 frame:0 TX packets:80 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:11502 (11.2 KiB) TX bytes:10035 (9.7 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
此時,我們查看一下網卡信息:
[root@centos65x64 ~]# ll /etc/sysconfig/network-scripts/ifcfg-*
-rw-r--r--. 1 root root 137 Jan 9 16:55 /etc/sysconfig/network-scripts/ifcfg-eth0
-rw-r--r--. 1 root root 254 Oct 10 2013 /etc/sysconfig/network-scripts/ifcfg-lo
[root@centos65x64 ~]#
顯然,查看IP信息時顯示的網卡信息與實際的網卡信息時一致的,都是eth0。
接下來從虛擬機A克隆一臺新的虛擬機B,查看其IP信息,顯示結果:
[root@centos65_x64_Logstash ~]# ifconfig -a eth1 Link encap:Ethernet HWaddr 00:0C:29:29:85:84 BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) [root@centos65_x64_Logstash ~]#
再查看一下虛擬機B的網卡信息:
[root@centos65x64 ~]# ll /etc/sysconfig/network-scripts/ifcfg-*
-rw-r--r--. 1 root root 137 Jan 9 16:55 /etc/sysconfig/network-scripts/ifcfg-eth0
-rw-r--r--. 1 root root 254 Oct 10 2013 /etc/sysconfig/network-scripts/ifcfg-lo
[root@centos65x64 ~]#
那麽問題來了,明明網卡名稱是eth0,為什麽在查看IP信息時顯示的是eth1呢?而且還沒有配置好正確的IP地址。
接著,我們再來看一下/etc/sysconfig/network-scripts/ifcfg-eth0
中的配置信息:
[root@centos65x64 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:0C:29:29:85:84
TYPE=Ethernet
UUID=eced92fe-8185-4081-a672-ac80e1d9fb95
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
發現什麽了嗎?執行命令ifconfig -a
顯示的eth1的MAC地址與/etc/sysconfig/network-scripts/ifcfg-eth0
中配置的MAC地址也不一樣!
解決方案
第一步:編輯MAC地址,將/etc/sysconfig/network-scripts/ifcfg-eth0
中配置的MAC地址修改為ifconfig -a
顯示的MAC地址。
[root@centos65x64 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:0C:29:6E:2B:3C
TYPE=Ethernet
UUID=eced92fe-8185-4081-a672-ac80e1d9fb95
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
第二步:修改網卡信息
[root@centos65x64 ~]# vim /etc/udev/rules.d/70-persistent-net.rules
1 # This file was automatically generated by the /lib/udev/write_net_rules
2 # program, run by the persistent-net-generator.rules rules file.
3 #
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
7 # PCI device 0x8086:0x100f (e1000)
8 #SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:6e:2b:3c", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
9
10 # PCI device 0x8086:0x100f (e1000)
11 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0C:29:29:85:84", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
12
13 # PCI device 0x8086:0x100f (e1000)
14 #SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:c7:e3:4c", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
註釋掉其最後一行名稱為eth1的信息,同時將其中名稱為eth0的網卡ATTR地址修改為ifconfig -a
顯示的MAC地址,重啟。
【參考】
http://blog.csdn.net/cyuyan112233/article/details/6585680 vmware 下找不到ifcfg-eth0的問題
VM克隆後找不到eth0的問題解決