有的时候当你用RAID从其他机器克隆一个系统到新硬盘中时,会出现新网卡不是从eth0开始,如果你想修改网卡从eth0开始,可以编辑"/etc/udev/rules.d/70-persistent-net.rules",如下

HostA:/dev # vi /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.

# PCI device 0x15ad:0x07b0 (vmxnet3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:a2:00:71", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

把eth1,改为eth0,保存后重启。

重启后发现机器ping不通,想办法连接到console,ifconfig发现无eth1


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:98 errors:0 dropped:0 overruns:0 frame:0
          TX packets:98 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:9059 (8.8 Kb)  TX bytes:9059 (8.8 Kb)

原来刚才修改完文件后并未修改eth config文件。

HostA:~ # cd /etc/sysconfig/network/
HostA:/etc/sysconfig/network # mv ifcfg-eth1 ifcfg-eth0
HostA:/etc/sysconfig/network # /etc/init.d/network restart
eth0      Link encap:Ethernet  HWaddr 00:50:56:A2:00:71
          inet addr:192.168.1.x  Bcast:192.168.1.255 Mask:255.255.255.0
          inet6 addr: fe80::250:56ff:fea2:71/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5576 errors:0 dropped:0 overruns:0 frame:0
          TX packets:553 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:501494 (489.7 Kb)  TX bytes:204124 (199.3 Kb)
 

OK,网络设定已经完成,但是发现还是无法ping通该主机,但是可以从主机内ping通网关。原来还需要修改routes

HostA:/etc/sysconfig/network # vi routes
default 192.168.1.254 - eth1
 

把eth1修改为eth0。保存,重启网络服务,ping通,搞定,收工