用VMware克隆CentOS 6.7后,发现系统只有eth1,而且/etc/sysconfig/network-scripts/下只有ifcfg-eth0文件,IP地址是动态获取的,虽然可以上网,但无法设置eth0的静态IP。
1、将上面的eth0注释掉,将下面的NAME="eth1" 改成NAME="eth0"
vim /etc/udev/rules.d/70-persistent-net.rules
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:72:15:45", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x1022:0x2000 (vmxnet)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:0b:c6:4d", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
~
修改的结果为:
# PCI device 0x1022:0x2000 (pcnet32) 这里的eth0已经被注释
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:72:15:45", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x1022:0x2000 (vmxnet) 将系统自动生成的eth1名称修改为eth0
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:0b:c6:4d", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
2、并将下面修改后的eth0的 ATTR{address}=="00:0c:29:0b:c6:4d",中的网卡地修改到 /etc/sysconfig/network-scripts/ifcfg-eth0 文件中,HWADDR="00:0c:29:0b:c6:4d",使他们对应。
DEVICE=eth0
HWADDR=00:0C:29:0b:c6:4d
TYPE=Ethernet
UUID=9c82314b-32ef-4e1f-af8d-540310fd74c6
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.103.231
NETMASK=255.255.255.0
GATEWAY=192.168.103.254
DNS1=192.168.103.254
DNS2=8.8.8.8
3、然后init 0或者reboot,eth0网卡正常使用。
(责任编辑:IT) |