Think before you speak, read before you think.

CentOS更换或添加网卡

有时更换网卡或换主板,原有的设备信息会存放在原来的磁盘。这时需要更新磁盘上对应的一些信息,有些情况下磁盘上的信息会自动更新,但自动更新不生效时,要手动操作。

在CentOS6下,添加网卡之后,先去查看网卡的mac地址。

cat /sys/class/net/eth1/address

接下来编辑/etc/udev/rules.d/70-persistent-net.rules(本来会自动生成),加上一行eth1相关的信息。

# 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 0x8086:0x10c9 (igb)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:a0:d1:ea:7a:68", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x10c9 (igb)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:a0:d1:ea:7a:69", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

最后到/etc/sysconfig/network-scripts/ifcfg-eth1,将hwaddr和uuid检查下,注释或删除掉都可以。

最后reboot重启即可以用。

udev知识:http://zh.wikipedia.org/wiki/Udev

参考:http://superuser.com/questions/332593/how-do-you-automatically-detect-a-new-network-card-in-centos-6-redhat


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *