linux下將eth1改為eth0

2021-06-28 15:19:42 字數 2540 閱讀 7997

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

linux

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

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

[user@localhost ~]$ ifconfig

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

inetaddr:192.168.1.108  bcast:192.168.1.255  mask:255.255.255.0

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

upbroadcast running multicast  mtu:1500  metric:1

rxpackets:313 errors:0 dropped:0 overruns:0 frame:0

txpackets:182 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000 

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

interrupt:19 base address:0x2000 

lo        linkencap:local loopback  

inetaddr:127.0.0.1  mask:255.0.0.0

inet6addr: ::1/128 scope:host

uploopback running  mtu:16436  metric:1

rxpackets:1788 errors:0 dropped:0 overruns:0 frame:0

txpackets:1788 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0 

rxbytes: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 generatedby the /lib/udev/write_net_rules

# program run by thepersistent-net-generator.rules rules file. #

# you can modify it, as long as you keepeach rule on a single line.

# pci device0x1022:0x2000 (pcnet32)

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下網絡卡eth1如何修改為eth0

正常來說,linux在識別網絡卡時第一張會是eth0,第二張才是eth1。有時候我們使用虛擬機器轉殖技術後網絡卡的資訊就會改變,新轉殖出來的虛擬主機網絡卡名字可能變為eth1.無論我們怎麼修改都無法改變,這就對我們使用n臺虛擬機器進行ha heartbeat實驗時造成了困擾。在這裡成這樣是因為複製系...

Linux 網絡卡配置eth1修改為eth0

在測試或生產環境中,經常會遇到轉殖的伺服器 虛擬機器 網絡卡配置經常也會轉殖為eth1,下面講如何將網絡卡配置修改為eth0 eth1網絡卡也可以正常使用,但是有些強逼症的同學看不習慣 配置環境 rhel6 目錄 步驟一 更改伺服器的網絡卡名,將轉殖的伺服器網絡卡配置修改為eth0 步驟二 修改網絡...

linux下 eth0變成eth1的原因

我發現這種情況一般是在用虛擬機器配置集群時容易發生 發生的原因 為什麼eth0會變成eth1?很多linux distribution使用udev動態管理裝置檔案,並根據裝置的資訊對其進行持久化命名。udev會在系統引導的過程中識別網絡卡,將mac位址和網絡卡名稱對應起來記錄在udev的規則指令碼中...