今天在测试opennebula,因为换了这个虚拟网络,发现启动的虚拟机的网卡改名了,eth0改为了eth3

udev: renamed network interface eth0 to eth3

因为虚拟机的配置是需要通过其他初始化脚本来生成的,所以网卡的设备名不能改变,需要把eth3修改为eth0

以rhel6为例,把以下文件作修改如下:

1、把eth0 ,eth1 ,eth2的相关行删除掉

2、把eth3的相关行保留,并把eth3改为eth0即可。

 

 
  
  1. [root@ovm0246 ~]# vim /etc/udev/rules.d/70-persistent-net.rules  
  2.  
  3. # This file was automatically generated by the/lib/udev/write_net_rules 
  4. # program, run by the persistent-net-generator.rules rules file. 
  5. # You can modify it, as long as you keep each rule on a single 
  6. # line, and change only the value of the NAMEkey
  7.  
  8. # PCI device 0x10ec:0x8139 (8139cp) (custom name provided by external tool) 
  9. SUBSYSTEM=="net"ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:12:34:56", ATTR{type}=="1", KERNEL=="eth*"NAME="eth0" 
  10.  
  11. # PCI device 0x10ec:0x8139 (8139cp) 
  12. SUBSYSTEM=="net"ACTION=="add", DRIVERS=="?*", ATTR{address}=="02:00:c0:a8:14:f9", ATTR{type}=="1", KERNEL=="eth*"NAME="eth1" 
  13.  
  14. # PCI device 0x10ec:0x8139 (8139cp) 
  15. SUBSYSTEM=="net"ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:e4:d4:1d", ATTR{type}=="1", KERNEL=="eth*"NAME="eth2" 
  16. # PCI device 0x10ec:0x8139 (8139cp) 
  17.  
  18. SUBSYSTEM=="net"ACTION=="add", DRIVERS=="?*", ATTR{address}=="02:00:c0:a8:14:fa", ATTR{type}=="1", KERNEL=="eth*"NAME="eth3"