正常来说,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.