1) 修改/etc/udev/rules.d/70-persistent-net.rules文件,刪除第一個網卡記錄,並將第二個的NAME="eth1"改爲NAME="eth0"
2) 複製第二條網卡記錄的MAC地址
原因:
很多Linux distribution使用udev動態管理設備文件,並根據設備的信息對其進行持久化命名。例如在
Debian etch中,udev會在系統引導的過程中識別網卡,將mac地址和網卡名稱對應起來記錄在udev的規則 腳本中。而VMware會自動生 成虛擬機的mac地址。這樣,由於基本系統的虛擬機已經記錄了該虛擬機的網 卡mac地址對應於網卡eth0,在克隆出的虛擬機中由於mac地址發生改 變,udev會自動將該mac對應於網 卡eth1。以此類推,udev會記錄所有已經識別的mac與網卡名的關係,所以每次克隆網卡名稱會自動加1, 而其 實kernel僅僅只識別到一張網卡,跟網卡名相關的網絡配置也未發生任何變化。
解決方法:
編輯如下文件
/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 0x15ad:0x07b0 (vmxnet3) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:bc:00:45", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x15ad:0x07b0 (vmxnet3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:bc:00:46", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
註釋掉eth0的那個段落,然後將eth1的修改爲eth0
修改網卡配置文件
/etc/sysconfig/network-scripts/ifcfg-eth0
把mac地址修改爲eth1的地址
HWADDR字段
重啓後生效
當然,如果你還什麼東西都沒裝,沒有在什麼配置文件中指定過eth0字段的話.直接cp或者mv ifcfg-eth0 ifcfg-eth1也是可以的