linux如何更改網卡的順序
在使用維護過程中,經常因為添加更換網卡導致網卡的順序產生不一至的現象。然而以前寫的shell腳本都已經ok了,沒有必要再去改動。所以只能更改網卡順序了,
我的CentOS6.3 更改位置在如下目錄:
/etc/udev/rules.d/70-persistent-net.rules 內容如下:(可以看到地址和它們的網卡物理地址是掛鉤的)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="54:e6:fc:6a:81:b5", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:07:e9:12:e8:f2", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x1106:0x3065 (via-rhine)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:11:09:97:32:1a", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
只要更改Name 的值就OK了。
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="54:e6:fc:6a:81:b5", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:07:e9:12:e8:f2", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x1106:0x3065 (via-rhine)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:11:09:97:32:1a", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
或者竟將eth0的MAC地址修改為改變後的地址就可以