1、首先,打开/etc/udev/rules.d/70-persistent-net.rules内容如下面例子所示:
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, and change only the value of the NAME= key.
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:8f:89:9
7", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:50:bd:1
7", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
记录下来当前最后一个NAME值:eth1
记录下来当前最后一个eth1网卡的mac地址值:00:0c:29:50:bd:17
2、接下来,打开/etc/sysconfig/network-scripts/ifcfg-eth0
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
展开内容如下:
DEVICE="eth2"
NM_CONTROLLED="yes"
ONBOOT="yes:"
TYPE=Ethernet
BOOTPROTO=dhcp
IPADDR=192.168.2.192
PREFIX=24
GATEWAY=192.168.2.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
HWADDR=00:0c:29:a2:f0:ab
修改DEVUCE=eth1(第一步中的name值)
修改HWADDR=00:0c:29:50:bd:17(第一步中网卡的mac地址值)
3、最后,重启网络
# service network restart
或者
# /etc/init.d/network restart
修改成功就可以上网啦,是不是很简单