網卡名字eth0,eth1的修改方法

VMWARE安裝虛擬機後,爲了避免重新安裝,一般會選擇直接複製虛擬機,但當打開心得拷貝後網卡信息會變化,原來是eth0 eth1 就會變成eth2 eth3,如果不想使用eth2 eth3下面的方法就可以更改網卡名稱。CentOS爲例

1.使用ip link 命令

ip link set eth0 name eth2
ip link set eth1 name eth0
ip link set eth2 name eth1

即可隨意更改名字,不過重啓後會失效。

2.更改配置文件(重啓不會失效)

直接可以在modprobe 中修改模塊別名,如使用udev的情況下,

 

  1. # vi /etc/udev/rules.d/70-persistent-net.rules  
  2.  
  3. 其中會有  
  4. # PCI device 0x8086:0x100f (e1000) (custom name provided by external tool)  
  5. SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:42:e7:61", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" 
  6.  
  7. # PCI device 0x8086:0x100f (e1000)  
  8. SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:42:e7:66", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1" 
  9.  
  10. # PCI device 0x8086:0x100f (e1000) (custom name provided by external tool)  
  11. SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:42:e7:6c", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2" 
  12.  
  13. # PCI device 0x8086:0x100f (e1000)  
  14. SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:42:e7:76", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3" 

 

爲了避免MAC地址和其他虛擬機重複,我們可以選擇更改下MAC地址,然後將eth0 eth1兩行註釋掉,將最後兩行中的eth2 和eth3更改爲eht0 和 eth1 。

完成後重啓,就會發現虛擬機網卡又變成eth0和eth1了。

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章