解決更換網卡後找不到eth0(Debian,Ubuntu)

来源:百度文库 编辑:神马文学网 时间:2024/04/29 12:13:14

解決更換網卡後找不到eth0(Debian,Ubuntu)

Debian與Ubuntu會紀錄網卡的MAC來判定網卡裝置,所以就算更換網卡,舊網卡還是一樣被判定成eth0,而其他新增的網卡會依照eth1,eth2...一直往下排下去

解決方法
修改/etc/udev/rules.d/內,persistent-net.rules檔案(會有prefix)

# PCI device 0x10de:0x00df (forcedeth)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:11:22:33:44:55", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x10de:0x00df (forcedeth)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="55:44:33:22:11:00", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

檔案內,舊網卡的資料已經被註解掉,但新網卡的資料中,NAME的部分是"eth1",將它改成"eth0",而舊網卡資料已經不需要了,可以直接刪除。

修改後如下

# PCI device 0x10de:0x00df (forcedeth)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="55:44:33:22:11:00", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

接著重新啟動

Shell$ shutdown -r now
張貼者: Cloud 位於 4/14/2009 04:27:00 下午 標籤: Linux  from site : http://nabeko-notebook.blogspot.com/2009/04/eth0debianubuntu.html 
 

Debian 更換網卡 eth1 2 3 4修正

在更換網卡後,會發現怎麼無法對eth0設定,輸入

debian:~# ifconfig -a

會發現eth0不見了,變成eth1

Debian只要在網卡的mac有變更就會新建一個裝置名稱,並將原本的註解停用,例如原本的網卡是eth0,但你只要換了一片網卡,就會變成eth1,會造成使用的不便,例如在iptables設定原則有用到eth0的部份,可能就失效了

debian修正的方式,編輯/etc/udev/rules.d/z25_persistent-net.rules

debian:~# vi vi /etc/udev/rules.d/z25_persistent-net.rules

fix
# PCI device 0x8086:0x100e (e1000)
#SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="08:00:27:17:2b:b2", NAME="eth0"

# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="08:00:27:17:3b:42", NAME="eth1"
to
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", DRIVERS=="?*", ATTRS{address}=="08:00:27:17:3b:42", NAME="eth0"
可以看到目前使用的eth1設定及之前eth0的mac設定,但之前的eth0被註解了,把之前eth0的部份刪除,再把"eth1"改為"eth0",存檔後重開機就ok了poster: thirteen in 下午 9:12 標籤: Debian, 學習筆記  from site :   http://thirteen-tw.blogspot.com/2008/08/debian-eth1-2-3-4.html