http://www.oklinux.cn 2009-06-04 linuxeden
會員收藏 游客收藏 【
大中小】
您查看的文章來源于http://www.oklinux.cn
這個方法用于解決
Ubuntu下更換網(wǎng)卡后,新網(wǎng)卡變更為eth1,并且源網(wǎng)卡的名稱eth0,無法給新網(wǎng)卡用的情況。也可以用于為網(wǎng)卡更名。
網(wǎng)卡MAC地址改變之后,在Linux中找到網(wǎng)卡,新的網(wǎng)卡會被識別為eth1或者更為靠后的網(wǎng)卡寫入到/etc/udev/rules.d/70-persistent-net.rules這個文件中,修改/etc/udev/rules.d/70-persistent-net.rules這個文件,將eth0的MAC地址修改為改變后的地址就可以。
編輯
/etc/udev/rules.d/70-persistent-net.rules
root@shangyuan-laptop:/etc/udev/rules.d# more 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:0x1713 (tg3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1e:ec:0f:79:f
6", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x4222 (iwl3945)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1f:3c:48:70:b
1", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0"
將其中的eth0,改為eth1,保存后重啟系統(tǒng)即可。
這個方法用于解決Ubuntu下更換網(wǎng)卡后,新網(wǎng)卡變更為eth1,并且源網(wǎng)卡的名稱eth0,無法給新網(wǎng)卡用的情況。也可以用于為網(wǎng)卡更名。
網(wǎng)卡MAC地址改變之后,在Linux中找到網(wǎng)卡,新的網(wǎng)卡會被識別為eth1或者更為靠后的網(wǎng)卡寫入到/etc/udev/rules.d/70-persistent-net.rules這個文件中,修改/etc/udev/rules.d/70-persistent-net.rules這個文件,將eth0的MAC地址修改為改變后的地址就可以。這個方法用于解決Ubuntu下更換網(wǎng)卡后,新網(wǎng)卡變更為eth1,并且源網(wǎng)卡的名稱eth0,無法給新網(wǎng)卡用的情況。也可以用于為網(wǎng)卡更名。
網(wǎng)卡MAC地址改變之后,在Linux中找到網(wǎng)卡,新的網(wǎng)卡會被識別為eth1或者更為靠后的網(wǎng)卡寫入到/etc/udev/rules.d/70-persistent-net.rules這個文件中,修改/etc/udev/rules.d/70-persistent-net.rules這個文件,將eth0的MAC地址修改為改變后的地址就可以。
編輯
/etc/udev/rules.d/70-persistent-net.rules
root@shangyuan-laptop:/etc/udev/rules.d# more 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:0x1713 (tg3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1e:ec:0f:79:f
6", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x4222 (iwl3945)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1f:3c:48:70:b
1", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0"
將其中的eth0,改為eth1,保存后重啟系統(tǒng)即可。
為了高效的解決在應用此方案時遇到的問題,歡迎大家使用eden附帶的文章評論功能提出使用問題或更好的解決方案。您的問題將得到及時的答復,謝謝。
更換主板后,Ubuntu無法訪問網(wǎng)絡
來源: ChinaUnix博客 日期: 2009.03.18 17:55 (共有0條評論)
我要評論Dell的Optilex745最近出了些問題, 報告給DELL后,那邊今天派人來了,解決方案倒是簡單, 直接更換了主板.
換完后,啟動了一下,沒去連接網(wǎng)絡, 所以就沒發(fā)現(xiàn)問題. 等到后來弄到機房啟動機器, 發(fā)現(xiàn)機器無法訪問網(wǎng)絡了.
用ifconfig一看,有兩個網(wǎng)絡設備:lo 和 eth1,
再查看一下/etc/network/interfaces,發(fā)現(xiàn)條目是lo和eth0,
執(zhí)行ifup --force eth0, 提示設備不存在
也就是說, 主板沒更換前, 網(wǎng)卡被命名為eth0,而現(xiàn)在被命名為eth1,eth0已經(jīng)不復存在了.
解決方法有兩種:
1 更改/etc/network/interfaces,將eth1都改為eth0, 我先這樣作了一下,而后/etc/init.d/networking restart重啟網(wǎng)絡服務, 結(jié)果就可以訪問網(wǎng)絡了.
我發(fā)現(xiàn)/etc底下還有某些配置文件使用eth0, 但是也不多. 這種情況好辦, 將這些文件用sed作一次替換就可以了, 使用這些配置的軟件就不會有問題了.
只是,google一下,發(fā)現(xiàn)其實有些軟件默認使用的就是eth0,eth1對他們來說無效.
2 所以,最好的方式,還是讓該網(wǎng)卡被命名為eth0, 看到有些機器上有ifrename,試了一下,發(fā)現(xiàn)不存在. 于是,就只有修改配置文件了, 該配置文件是/etc/udev/rules.d, 文件名是:70-persistent-net.rules
該文件內(nèi)容為:
# 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.
# PCI device 0x14e4:0x167a (tg3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:19:b9:43:c7:86", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x14e4:0x167a (tg3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1a:a0:bd:14:05", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
修改一下該文件,將eth0的那行注釋掉,而后將eth1改為eth0
而后再重啟網(wǎng)絡服務, 這樣該網(wǎng)卡就變?yōu)榱薳th0,既不需修改其他配置文件,又不會對以后裝軟件造成影響了.