對這文章發表回應
發表限制: 非會員 可以發表
linux Kernel 2.6 之後已經改用 udev 來管理 /dev 了,但是常用的 SuSE 是使用 ifup 跟配合 /etc/sysconfig/network/ifcfg-eth-MAC address 來辨別哪一張網路卡要 bind 哪個 IP,但是 debian or ubuntu 還是用 eth0 eth1 來作為設定 (/etc/network/interface),但他們都是用 udev 的 rules 去產生 persistent network interface name,也就是 eth0 代表哪一張卡,還是透過 udev 去設定的。
http://suseforums.net/index.php?showtopic=29536.
我的問題在於開機之後,我希望更改 Mac Address 再使用 network card,這會導致 ubuntu 的 udev rules 每次都重新產生 eth0_rename 這樣的 interface name, 導致啟動時網路設定會錯誤。
經過一些研究,整理資料如下:
/etc/udev/rules.d/70-persistent-net.rules 是由同目錄的 75-persistent-net-generator.rules 去呼叫 /lib/udev/write_net_rules 產生。而這個 script 會根據 mac address 來產生 /etc/udev/rules.d/70-persistent-net.rules 這個檔案。然而我因為更改了 mac 所以會造成原來這個 device name 被發現而 rename (fixme)。
所以解法是,不要利用 mac address 來區分 eth0 還是 eth1,直接用 driver 來分就好了。(正好我兩張卡不同 driver),然後將 75-persistent-net-generator.rules 丟到垃圾桶即可。
# PCI device 0x8086:0x109a (e1000)
SUBSYSTEM=="net", DRIVERS=="e1000", NAME="eth0"
# PCI device 0x1113:0x1216 (tulip)
SUBSYSTEM=="net", DRIVERS=="tulip", NAME="eth1"
如果是相同的 driver 兩張卡的情況我就還沒碰過,碰到再說囉!
Note:
/etc/modprobe.d/aliases 中加上
alias eth0 e1000
Debian/ubuntu 似乎要寫在
/etc/modutils/ 裡面?
http://checko.blogspot.com/2004/08/linux-debian_27.html
詳細 rules 寫法跟其他參考資料
http://www.debianhelp.co.uk/udev.htmhttp://forum.ubuntu.org.cn/viewtopic.php?p=641452&sid=8232abf6a0d9bd3d71ea5bb9656c5a3b
http://www.linuxfromscratch.org/blfs/view/development/chapter07/network.html
原文出處:[ubuntu] udev 固定 netowrk device name @ 工作小錦囊 :: 隨意窩 Xuite日誌