CentOS裡ifcfg的device指的是什嗎?

來源:互聯網
上載者:User
#cat ifcfg-eth0device=eth0...

原因:有個多節點伺服器遷移機房,怕碰壞了,先把硬碟拆下來,結果放回去的時候記錯順序了,造成開機
網卡對不上,原有的eth01變成eth23,知道怎麼搞。

分析:

CentOS下找不到eth0裝置的解決方案

經過百度,瞭解了一些資訊,特此記錄在此,以備忘。 為什麼eth0會變成eth1? 很多Linux
distribution使用udev動態管理裝置檔案,並根據裝置的資訊對其進行持久化命名。udev會在系統引導的過程中識別網卡,將mac地址和網卡名稱對應起來記錄在udev的規則指令碼中。而對於新的虛擬機器,VMware會自動為虛擬機器的網卡產生MAC地址,當你複製或者重裝虛擬機器軟體時,由於你使用的是以前系統虛擬硬碟的資訊,而該系統中已經有eth0的資訊,對於這個新的網卡,udev會自動將其命名為eth1(累加的原則),所以在你的系統啟動後,你使用ifconfig看到的網卡名為eth1。

這裡的eth0是在/etc/udev/rules.d/70-persistent-net.rules定義的

# 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, and change only the value of the NAME= key.# PCI device 0x8086:0x100f (e1000)SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:xx", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

解決:
為什麼eth0會變成eth1?

如何恢複到eth0?
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# 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 0x1022:0x2000 (pcnet32)SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:5a:6c:73", ATTR{type}=="1",KERNEL=="eth*", NAME="eth0"SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:a9:22:9d", ATTR{type}=="1",KERNEL=="eth*", NAME="eth1"  

CentOS下找不到eth0裝置的解決方案
開啟該檔案,這時你會發現,裡面有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網卡的狀態了。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.