虚拟机上面安装CentOS 6,添加一块网卡之后发现新添加的网卡无法自动启动,在CentOS 5中新添加网卡之后是可以直接自动启动的。
输入ifconfig之后如下:
eth0 Link encap:Ethernet HWaddr 00:0C:29:D4:80:93
inet addr:192.168.0.204 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fed4:8093/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:300 errors:0 dropped:0 overruns:0 frame:0
TX packets:128 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:29737 (29.0 KiB) TX bytes:14667 (14.3 KiB)
Interrupt:19 Base address:0x2000
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:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
可见没有eth1的信息
再输入dmesg | grep eth
[root@localhost ~]# dmesg | grep eth
eth0: registered as PCnet/PCI II 79C970A
eth1: registered as PCnet/PCI II 79C970A
eth0: link up
说明eth1网卡已经被系统所识别,这样我们就可以查看关于网络的udev,这个udev的具体网卡序号的配置文件是:/etc/udev/rules.d/70-persistent-net.rules
cat /etc/udev/rules.d/70-persistent-net.rules 结果如下:
[root@localhost ~]# cat /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:d4:80:93", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x1022:0x2000 (pcnet32)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:d4:80:9d", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
这样我们就找到了eth1的mac地址了,然后把eth0的配置文件ifcfg-eth0复制一份改成ifcfg-eth1修改设备名、mac地址、IP地址重新启动网络服务就OK了!