ACTION=="add", SUBSYSTEM=="net", IMPORT{program}="/lib/udev/rename_device"
SUBSYSTEM=="net", RUN+="/etc/sysconfig/network-scripts/net.hotplug"
DRIVER=="e1000",ID=="0000:02:02.0",NAME="eth1"
将网卡的真实 MAC 地址写入网卡的静态配置文件中 ifcfg-ethX,添加一行内容:
HWADDR=xx:xx:xx:xx:xx:xx
其中,xx:xx:xx:xx:xx:xx 为网卡的 MAC 地址
01:00.0 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
01:00.1 Ethernet controller: Intel Corporation 82576 Gigabit Network Connection (rev 01)
04:00.0 Ethernet controller: Intel Corporation 82571EB Gigabit Ethernet Controller (rev 06)
04:00.1 Ethernet controller: Intel Corporation 82571EB Gigabit Ethernet Controller (rev 06)
alias eth0 igb
alias eth1 igb
alias eth2 e1000e
alias eth3 e1000e
[root@xxx ~]# ethtool -i eth0
driver: igb
version: 2.4.8
firmware-version: 1.4-3
bus-info: 0000:01:00.0
[root@xxx ~]# ethtool -i eth1
driver: e1000
version: 7.3.20-k2-NAPI
firmware-version: 5.6-2
bus-info: 0000:04:00.1
[root@xxx ~]# ethtool -i eth3
driver: igb
version: 2.4.8
firmware-version: 1.4-3
bus-info: 0000:01:00.1
Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
lo:7476419692 1424305 0 0 0 0 0 0 7476419692 1424305 0 0 0 0 0 0
__tmp358702611: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
eth1:51413066439 479078418 0 536 0 0 0 1 1146871974797 787610625 0 0 0 0 0 0
eth0: 1825946 30420 0 0 0 0 0 0 1182 23 0 0 0 0 0 0
eth3:48131386965 459275416 0 0 0 0 0 0 1147067104897 789553247 0 0 0 0 0 0
bond0:99544453404 938353834 0 536 0 0 0 1 2293939079694 1577163872 0 0 0 0 0 0
这个可能是pci枚举时, 深度优先 or 广度优先造成的不同。
boot时加参数可以指定枚举用的方式。
赞一个,linux下,大部分设备的设备名称,都是可以通过udev规则来指定的,不同的发行版,规则稍有差异,但不大,参考一下manual应该就可以了。rh与suse的规则文件,都是放置于/etc/udev/rules.d/目录下,只需要更改对应文件中的配置,然后重启机器即可。
# cat /etc/udev/rules.d/70-persistent-net.rules
# This file maintains persistent names for network interfaces.
# See udev(7) for syntax.
#
# Entries are automatically added by the 75-persistent-net-generator.rules
# file; however you are also free to add your own entries.
# PCI device 0x14e4:0x1677 (tg3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:13:72:8d:11:22", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x10ec:0x8139 (8139too)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="d8:5d:4c:6f:33:44", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
先在都是通过 udev 绑定网卡名称和具体网卡 ID 号了
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 0x10ec:0x8139 (8139cp) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:db:6b:b0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x10ec:0x8139 (8139cp) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:32:ed:8d", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x10ec:0x8139 (8139cp)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="52:54:00:eb:f5:b9", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
# PCI device 0x10ec:0x8139 (8139cp)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:16:36:18:14:51", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3"
# PCI device 0x10ec:0x8139 (8139cp)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:16:36:84:02:29", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth4"
# PCI device 0x10ec:0x8139 (8139cp)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:16:36:63:ef:de", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth5"
ACTION=="add", SUBSYSTEM=="net", IMPORT{program}="/lib/udev/rename_device"
SUBSYSTEM=="net", RUN+="/etc/sysconfig/network-scripts/net.hotplug"
DRIVER=="e1000",ID=="0000:02:02.0",NAME="eth1"
QUOTE:alias eth0 igb
alias eth1 igb
alias eth2 e1000e
alias eth3 e1000e
我想问的就是,我做了bonding后,用netstat -rn看缺省网关的iface是一个物理网口而不是bond0,这造成我做断网测试的时候,只有一个网口能联通外网,另一个网口active的时候只能连到内网不能通过网关连到外网。
我添加了这几句:
SUBSYSTEM=="net",ACTION=="add",BUS=="pci", ID=="0000:25:00.0",DRIVER=="e1000e",NAM ...
waleliu 发表于 2011-02-27 13:00
# cat /etc/udev/rules.d/60-net.rules
ACTION=="add", SUBSYSTEM=="net", IMPORT{program}="/lib/udev/rename_device"
SUBSYSTEM=="net", RUN+="/etc/sysconfig/network-scripts/net.hotplug"
DRIVER=="e1000e",ID=="0000:03:00.0",NAME="eth0"
DRIVER=="e1000e",ID=="0000:03:00.1",NAME="eth1"
DRIVER=="e1000e",ID=="0000:06:00.0",NAME="eth2"
DRIVER=="e1000e",ID=="0000:07:00.0",NAME="eth3"
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |