1. 程式人生 > >虛擬機器網絡卡與配置檔案不匹配 Device eth0 does not seem to bepresent

虛擬機器網絡卡與配置檔案不匹配 Device eth0 does not seem to bepresent

安裝虛擬機器並複製之後,面臨一個問題就是MAC的變更。

當Vmware第一次打開復制虛擬機器的時候,會詢問你虛擬機器來源 

如果你選擇 I Copy It 那麼虛擬機器會自動幫你變更MAC地址。

或者你可以自己手工變更MAC地址

此時就會發現ifconfig與 /etc/sysconfig/network-scripts/中配置檔案無法對應的情況。

[[email protected] ~]# ifconfig 
eth1      Link encap:Ethernet  HWaddr 00:0C:29:07:92:17  
          inet addr:192.168.2.108  Bcast:192.168.2.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe77:9217/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:313 errors:0 dropped:0 overruns:0 frame:0
          TX packets:105 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:36840 (35.9 KiB)  TX bytes:15389 (15.0 KiB)
檢視配置檔案
[[email protected] ~]# ll /etc/sysconfig/network-scripts/ifcfg-*
-rw-r--r--. 3 root root 286 Oct 27 17:49 /etc/sysconfig/network-scripts/ifcfg-eth0
-rw-r--r--. 1 root root 254 Apr 27  2012 /etc/sysconfig/network-scripts/ifcfg-lo


原因在於redhat6 在發現MAC地址變動後在udev配置檔案中自動增加一條配置資訊
[[email protected] ~]# cat /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:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:07:92:17", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:07:92:17", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"


問題就出現在這裡。

此時只需要

1 刪除帶有舊的MAC地址的配置

2 講帶有新MC地址的配置檔案後NAME修改為eth0

3 重新初始化UDEV start_udev

4 重啟網路service network restart

就可以了。。