#cat ifcfg-eth0
device=eth0
...
原因:有個多節(jié)點服務(wù)器遷移機房,怕碰壞了,先把硬盤拆下來,結(jié)果放回去的時候記錯順序了,造成開機 網(wǎng)卡對不上,原有的eth01變成eth23,知道怎么搞。
分析:
CentOS下找不到eth0設(shè)備的解決方法
經(jīng)過百度,了解了一些信息,特此記錄在此,以備忘。 為什么eth0會變成eth1? 很多Linux distribution使用udev動態(tài)管理設(shè)備文件,并根據(jù)設(shè)備的信息對其進(jìn)行持久化命名。udev會在系統(tǒng)引導(dǎo)的過程中識別網(wǎng)卡,將mac地址和網(wǎng)卡名稱對應(yīng)起來記錄在udev的規(guī)則腳本中。而對于新的虛擬機,VMware會自動為虛擬機的網(wǎng)卡生成MAC地址,當(dāng)你克隆或者重裝虛擬機軟件時,由于你使用的是以前系統(tǒng)虛擬硬盤的信息,而該系統(tǒng)中已經(jīng)有eth0的信息,對于這個新的網(wǎng)卡,udev會自動將其命名為eth1(累加的原則),所以在你的系統(tǒng)啟動后,你使用ifconfig看到的網(wǎng)卡名為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?
如何恢復(fù)到eth0? udev記錄網(wǎng)絡(luò)規(guī)則的腳本為:/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設(shè)備的解決方法 打開該文件,這時你會發(fā)現(xiàn),里面有eth0,eth1兩個網(wǎng)卡的信息,但實際上你ifconfig時只能發(fā)現(xiàn)eth1一個網(wǎng)卡的信息,這時因為eth0根本就不存在。 將其中eth0的信息刪掉,并將eth1信息中的設(shè)備名改為eth0,重啟系統(tǒng),你看到的網(wǎng)卡就是eth0了,或者刪掉其中所有的信息重啟系統(tǒng)udev會幫你發(fā)現(xiàn)新的設(shè)備的。 另外還有一個啟動腳本文件/etc/sysconfig/network-scripts/ifcfg-eth0,該文件中的mac地址為原來eth0網(wǎng)卡的物理地址,而虛擬機為eth1分配新的物理地址,故啟動腳本中的信息與實際信息時不匹配的,將MAC的地址信息修改為70-persistent-net.rules中的eth1的MAC地址,再次重啟網(wǎng)絡(luò),就完全恢復(fù)到以前eth0網(wǎng)卡的狀態(tài)了。