修改RHEL6.3的網路卡名稱

perfychi發表於2014-03-03
From:
正常來說,linux在識別網路卡時第一張會是eth0,第二張才是eth1。在這裡成這樣是因為複製系統的過程中複製的檔案已經有一個網路卡在/etc/udev/rules.d/70-persistent-net.rules被識別成了eth0,而虛擬機器中的識別成了eth1。

解決方法是:
編輯/etc/udev/rules.d/70-persistent-net.rules
找到與ifconfig -a得出的MAC相同的一行(NAME='eth1'這一行),把它改為"NAME=eth0 ",然後把上面一行(NAME='eth0')刪除掉。
編輯/etc/sysconfig/network-script/ifcfg-eth0
把MAC改為正確的,把UUID刪掉。
編輯/etc/sysconf/network,把hostname也改一下。
重啟生效!




say you have two nics installed on the system, eth0, and eth1.
At some times latter, you removed eth0 from the system.
Now eth1 is the only nic in your machine... and you want to rename this nic(eth1) as eth0.


following are the steps:


# rcnetwork stop
# vi /etc/udev/rules.d/30-net_persistent_names.rules


here you find a line as
SUBSYSTEM=="net", ACTION=="add", SYSFS{address}=="00:02:b3:22:84:f3", IMPORT="/lib/udev/rename_netiface %k eth1"


simply change eth1, as eth0,
SUBSYSTEM=="net", ACTION=="add", SYSFS{address}=="00:02:b3:22:84:f3", IMPORT="/lib/udev/rename_netiface %k eth0"


save and exit




Now execute the following command
# /lib/udev/rename_netiface
i.e
# /lib/udev/rename_netiface eth1 eth0


# rcnetwork start


DONE 


even we can give any valid name to our nic, say e.g we want to name our eth0 as lan0, then
# rcnetwork stop
# vi /etc/udev/rules.d/30-net_persistent_names.rules
here you find a line as
SUBSYSTEM=="net", ACTION=="add", SYSFS{address}=="00:02:b3:22:84:f3", IMPORT="/lib/udev/rename_netiface %k eth0"


simply change eth1, as lan0,
SUBSYSTEM=="net", ACTION=="add", SYSFS{address}=="00:02:b3:22:84:f3", IMPORT="/lib/udev/rename_netiface %k lan0"


Now execute the following command
# /lib/udev/rename_netiface eth0 lan0


NOTE:
say we gave our nic a name as lanX, nicX, or intX(i.e non ethX name), and then want to change the name from lan0 to eth0, all the above steps are required, and reboot too.


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27042095/viewspace-1098613/,如需轉載,請註明出處,否則將追究法律責任。

相關文章