Linux的網絡卡由eth0變成了eth1,如何修復

2021-07-11 09:10:10 字數 2240 閱讀 1116

使用wmware安裝了linux,安裝成功後,使用的網絡卡是eth0,沒有eth1。但是用過一段時間後,不知道為什麼eth0無法使用,系統卻自動生成了eth1網絡卡,這可以使用ifconfig命令看的到。

[user@localhost ~]$ ifconfig

eth1 link encap:ethernet hwaddr 00:0c:29:a9:22:9d

inet addr:192.168.1.108 bcast:192.168.1.255 mask:255.255.255.0

inet6 addr: fe80::20c:29ff:fea9:229d/64 scope:link

up broadcast running multicast mtu:1500 metric:1

rx packets:313 errors:0 dropped:0 overruns:0 frame:0

tx packets:182 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

rx bytes:67356 (65.7 kib) tx bytes:26612 (25.9 kib)

interrupt:19 base address:0x2000

lo link encap:local loopback

inet addr:127.0.0.1 mask:255.0.0.0

inet6 addr: ::1/128 scope:host

up loopback running mtu:16436 metric:1

rx packets:1788 errors:0 dropped:0 overruns:0 frame:0

tx packets:1788 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

rx bytes:89560 (87.4 kib) tx bytes:89560 (87.4 kib)

使用service network restart指令來重新啟動網路服務時,會看到有eth0網絡卡不存在的提示。

為什麼eth0會變成eth1?

很多linux distribution使用udev動態管理裝置檔案,並根據裝置的資訊對其進行持久化命名。udev會在系統引導的過程中識別網絡卡,將mac位址和網絡卡名稱對應起來記錄在udev的規則指令碼中。而對於新的虛擬機器,vmware會自動為虛擬機器的網絡卡生成mac位址,當你轉殖或者重灌虛擬機器軟體時,由於你使用的是以前系統虛擬硬碟的資訊,而該系統中已經有eth0的資訊,對於這個新的網絡卡,udev會自動將其命名為eth1(累加的原則),所以在你的系統啟動後,你使用ifconfig看到的網絡卡名為eth1。

如何恢復到eth0?

在fedora中,udev記錄網路規則的指令碼為:/etc/udev/rules.d/70-persistent-net.rules

[user@localhost ~]$ vi /etc/udev/rules.d/70-persistent-net.rules

**# this file was automatically generated by the /lib/udev/write_net_rules

subsystem==」net」, action==」add」, drivers==」?「, attr==」00:0c:29:5a:6c:73」, attr==」1」, kernel==」eth「, name=」eth0」

subsystem==」net」, action==」add」, drivers==」?「, attr==」00:0c:29:a9:22:9d」, attr==」1」, kernel==」eth「, name=」eth1」

開啟該檔案,這時你會發現,裡面有eth0,eth1兩個網絡卡的資訊,但實際上你ifconfig時只能發現eth1乙個網絡卡的資訊,這時因為eth0根本就不存在。

將其中eth0的資訊刪掉,並將eth1資訊中的裝置名改為eth0,重啟系統,你看到的網絡卡就是eth0了,或者刪掉其中所有的資訊重啟系統udev會幫你發現新的裝置的。

另外還有乙個啟動指令碼檔案/etc/sysconfig/network-scripts/ifcfg-eth0,該檔案中的mac位址為原來eth0網絡卡的實體地址,而虛擬機器為eth1分配新的實體地址,故啟動指令碼中的資訊與實際資訊時不匹配的,將mac的位址資訊修改為70-persistent-net.rules中的eth1的mac位址,再次重啟網路,就完全恢復到以前eth0網絡卡的狀態了。

Linux的網絡卡由eth0變成了eth1,如何修復

環境 centos 6.5 裝在u 盤中的。可以隨身帶 說明 我在一台機器上在u盤上裝好系統以後,網路什麼的都能正常使用,然後我換到另一台機器的時候問題出現了。就是無法使用網路。表現 ifconfig 只顯示lo ifconfig a 顯示lo 和 eth1 沒 eth0 檢視 etc syscon...

Linux的網絡卡由eth0變成了eth1

相信有很多朋友,使用虛擬機器複製多個linux系統,其中可能會有遇到上面2個現象,現象1 linux的網絡卡由eth0變成了eth1 現象2 網絡卡故障 彈出介面eth0 錯誤 沒有找到合適的裝置 沒有找到可用於鏈結system eth0 的 那麼下文基本上可以幫助你,該如何修復現象 為什麼會出現這...

linux修改網絡卡名為eth0

方法1 1.編輯網絡卡的配置檔案 vi etc sysconfig network scripts ifcfg ens33 將裡面的name和device項修改為eth0,onboot修改為yes。2.重新命名網絡卡配置檔案ifcfg ens33為ifcfg eth0。cd etc sysconfi...