Skip to content


centos固定多网卡启动顺序

系统插上PCI网卡每次重启后顺序可能都会不同,影响nagios检控准确度.

CentOS6

在CentOS6中,具体网卡的配置文件在/etc/udev/rules.d/70-persistent-net.rules
cat /etc/udev/rules.d/70-persistent-net.rules

  1. # PCI device 0x14e4:0x163b (bnx2) (custom name provided by external tool)
  2. SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="78:2b:cb:xx:xx:02", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
  3.  
  4. # PCI device 0x14e4:0x163b (bnx2) (custom name provided by external tool)
  5. SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="78:2b:cb:xx:xx:03", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
  6.  
  7. # USB device 0x9710:0x7830 (usb) (custom name provided by external tool)
  8. SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:60:6e:xx:xx:f6", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
  9.  
  10. # PCI device 0x14e4:0x165a (tg3)
  11. SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:10:18:xx:xx:51", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3"
  12.  
  13. # PCI device 0x8086:0x10c9 (igb)
  14. SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:xx:xx:a1", ATTR{type}=="1", KERNEL=="eth*", NAME="eth4"
  15.  
  16. # PCI device 0x8086:0x10c9 (igb)
  17. SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:xx:xx:a0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth5"

删除(usb),(tg3)并调整bnx2及igb的名称,调整后如下

  1. # PCI device 0x14e4:0x163b (bnx2) (custom name provided by external tool)
  2. SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="78:2b:cb:xx:xx:02", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
  3.  
  4. # PCI device 0x14e4:0x163b (bnx2) (custom name provided by external tool)
  5. SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="78:2b:cb:xx:xx:03", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
  6.  
  7. # PCI device 0x8086:0x10c9 (igb)
  8. SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:xx:xx:a1", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
  9.  
  10. # PCI device 0x8086:0x10c9 (igb)
  11. SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1b:21:xx:xx:a0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3"

配置网卡文件
同时修改/etc/sysconfig/network-scripts/ifcfg-eth*网卡配置文件,修改设备名和MAC地址和udev对应.
同时注意ip地址和网关.

重启服务器
reboot

centos5.8

dmesg中看到intel的pci网卡先于内置网卡

  1. e1000e: Intel(R) PRO/1000 Network Driver - 1.4.4-k
  2. e1000e: Copyright(c) 1999 - 2011 Intel Corporation.
  3. e1000e 0000:03:00.0: Disabling ASPM  L1
  4. GSI 25 sharing vector 0x52 and IRQ 25
  5. ACPI: PCI Interrupt 0000:03:00.0[A] -> GSI 38 (level, low) -> IRQ 82
  6. PCI: Setting latency timer of device 0000:03:00.0 to 64
  7. EDAC MC: Ver: 2.0.1 Feb 21 2012
  8. e1000e 0000:03:00.0: eth0: (PCI Express:2.5GT/s:Width x4) 00:15:17:2d:52:c4
  9. e1000e 0000:03:00.0: eth0: Intel(R) PRO/1000 Network Connection
  10. e1000e 0000:03:00.0: eth0: MAC: 0, PHY: 4, PBA No: D28207-005
  11. e1000e 0000:03:00.1: Disabling ASPM  L1
  12. GSI 26 sharing vector 0x62 and IRQ 26
  13. ACPI: PCI Interrupt 0000:03:00.1[B] -> GSI 45 (level, low) -> IRQ 98
  14. PCI: Setting latency timer of device 0000:03:00.1 to 64
  15. sd 0:0:0:0: Attached scsi generic sg0 type 0
  16. sd 0:0:1:0: Attached scsi generic sg1 type 0
  17. scsi 3:0:0:0: Attached scsi generic sg2 type 5
  18. e1000e 0000:03:00.1: eth1: (PCI Express:2.5GT/s:Width x4) 00:15:17:2d:52:c5
  19. e1000e 0000:03:00.1: eth1: Intel(R) PRO/1000 Network Connection
  20. e1000e 0000:03:00.1: eth1: MAC: 0, PHY: 4, PBA No: D28207-005
  21. bnx2: Broadcom NetXtreme II Gigabit Ethernet Driver bnx2 v2.1.11 (July 20, 2011)
  22. GSI 27 sharing vector 0x72 and IRQ 27
  23. ACPI: PCI Interrupt 0000:01:00.0[A] -> GSI 36 (level, low) -> IRQ 114
  24. PCI: Setting latency timer of device 0000:01:00.0 to 64
  25. eth2: Broadcom NetXtreme II BCM5716 1000Base-T (C0) PCI Express found at mem da000000, IRQ 114, node addr 0024e86cd577
  26. GSI 28 sharing vector 0x7A and IRQ 28
  27. ACPI: PCI Interrupt 0000:01:00.1[B] -> GSI 48 (level, low) -> IRQ 122
  28. PCI: Setting latency timer of device 0000:01:00.1 to 64
  29. eth3: Broadcom NetXtreme II BCM5716 1000Base-T (C0) PCI Express found at mem dc000000, IRQ 122, node addr 0024e86cd578
  30. sr0: scsi3-mmc drive: 24x/24x cd/rw xa/form2 cdda tray

cat /etc/udev/rules.d/60-net.rules

  1. ACTION=="add", SUBSYSTEM=="net", IMPORT{program}="/lib/udev/rename_device"
  2. SUBSYSTEM=="net", RUN+="/etc/sysconfig/network-scripts/net.hotplug"

查看driver和bus-info
ethtool -i eth0
driver: bnx2
version: 2.1.11
firmware-version: bc 4.6.4 NCSI 1.0.6
bus-info: 0000:01:00.0
ethtool -i eth1
driver: bnx2
version: 2.1.11
firmware-version: bc 4.6.4 NCSI 1.0.6
bus-info: 0000:01:00.1
ethtool -i eth2
driver: e1000e
version: 1.4.4-k
firmware-version: 5.11-2
bus-info: 0000:03:00.0
ethtool -i eth3
driver: e1000e
version: 1.4.4-k
firmware-version: 5.11-2
bus-info: 0000:03:00.1

编辑顺序
DRIVER指driver: e1000e
ID是指bus-info:PCI ID

vi /etc/udev/rules.d/60-net.rules

  1. DRIVER=="bnx2",ID=="0000:01:00.0",NAME="eth0"
  2. DRIVER=="bnx2",ID=="0000:01:00.1",NAME="eth1"
  3. DRIVER=="e1000e",ID=="0000:03:00.0",NAME="eth2"
  4. DRIVER=="e1000e",ID=="0000:03:00.1",NAME="eth3"

重启
reboot

  1. input: PC Speaker as /class/input/input0
  2. bnx2: Broadcom NetXtreme II Gigabit Ethernet Driver bnx2 v2.1.11 (July 20, 2011)
  3. GSI 25 sharing vector 0x52 and IRQ 25
  4. ACPI: PCI Interrupt 0000:01:00.0[A] -> GSI 36 (level, low) -> IRQ 82
  5. PCI: Setting latency timer of device 0000:01:00.0 to 64
  6. eth0: Broadcom NetXtreme II BCM5716 1000Base-T (C0) PCI Express found at mem da000000, IRQ 82, node addr 0024e86cd577
  7. GSI 26 sharing vector 0x5A and IRQ 26
  8. ACPI: PCI Interrupt 0000:01:00.1[B] -> GSI 48 (level, low) -> IRQ 90
  9. PCI: Setting latency timer of device 0000:01:00.1 to 64
  10. eth1: Broadcom NetXtreme II BCM5716 1000Base-T (C0) PCI Express found at mem dc000000, IRQ 90, node addr 0024e86cd578
  11. EDAC MC: Ver: 2.0.1 Feb 21 2012
  12. e1000e: Intel(R) PRO/1000 Network Driver - 1.4.4-k
  13. e1000e: Copyright(c) 1999 - 2011 Intel Corporation.
  14. e1000e 0000:03:00.0: Disabling ASPM  L1
  15. GSI 27 sharing vector 0x62 and IRQ 27
  16. ACPI: PCI Interrupt 0000:03:00.0[A] -> GSI 38 (level, low) -> IRQ 98
  17. PCI: Setting latency timer of device 0000:03:00.0 to 64
  18. sd 0:0:0:0: Attached scsi generic sg0 type 0
  19. sd 0:0:1:0: Attached scsi generic sg1 type 0
  20. scsi 3:0:0:0: Attached scsi generic sg2 type 5
  21. e1000e 0000:03:00.0: eth2: (PCI Express:2.5GT/s:Width x4) 00:15:17:2d:52:c4
  22. e1000e 0000:03:00.0: eth2: Intel(R) PRO/1000 Network Connection
  23. e1000e 0000:03:00.0: eth2: MAC: 0, PHY: 4, PBA No: D28207-005
  24. e1000e 0000:03:00.1: Disabling ASPM  L1
  25. GSI 28 sharing vector 0x72 and IRQ 28
  26. ACPI: PCI Interrupt 0000:03:00.1[B] -> GSI 45 (level, low) -> IRQ 114
  27. PCI: Setting latency timer of device 0000:03:00.1 to 64
  28. e1000e 0000:03:00.1: eth3: (PCI Express:2.5GT/s:Width x4) 00:15:17:2d:52:c5
  29. e1000e 0000:03:00.1: eth3: Intel(R) PRO/1000 Network Connection
  30. e1000e 0000:03:00.1: eth3: MAC: 0, PHY: 4, PBA No: D28207-005
  31. sr0: scsi3-mmc drive: 24x/24x cd/rw xa/form2 cdda tray

nagios的check_traffic.sh脚本查看顺序
./check_traffic.sh -V 2c -C privatepass -H localhost -L

  1. List Interface for host localhost.
  2. Interface index 1 orresponding to  lo
  3. Interface index 2 orresponding to  eth0
  4. Interface index 3 orresponding to  eth1
  5. Interface index 4 orresponding to  eth2
  6. Interface index 5 orresponding to  eth3

Posted in linux 维护优化.

Tagged with , .


No Responses (yet)

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.