Linux network card eth0 became the eth1 or eth2, how to fix? ?

Background: When do under linux distributed test and re-installed two linux virtual machine, the results of the distributed script does not do a good job, did not make distributed.

          Today, I want to practice your linux command to open vmware, start linux1 virtual machine, use ifconfig -a, view ip, the results did not show the card eth0, no ip, the show has become eth2.

          

          I think the other virtual machines will not do so, has launched a linux2 virtual machine, use ifconfig -a, view ip, the results show the card eth0, but did not display ip.

       

           Oh, good gas, previously used properly ah. . . . . Find the beginning of the problem -

First, use ifconfig -a show became a card eth2, but no ip display.

the reason:

Many Linux distribution with udev dynamic device file management, and information equipment based on its persistent name. udev identifies the card during system boot, the mac address and name card association rule script recorded in the udev. As for the new virtual machine, VMware will automatically generate a MAC address for the network card of the virtual machine, when you clone a virtual machine or reinstall the software, because you are using a virtual hard disk before the system information, and the system has the eth0 information for this new card, udev will automatically be named eth1 (cumulative principle), so when your system boots, you use the card to see ifconfig called eth1.

solve:

? How to restore to eth0
script in fedora, udev rules for recording network: /etc/udev/rules.d/70-persistent-net.rules
[the User @ localhost ~] $ vi /etc/udev/rules.d/ 70-persistent-net.rules

Open the file, then you will find that there are eth0, eth1, eht2 three card information, but in fact can only find information eth2 a card when you ifconfig, this time because eth0 does not exist.

方法一:将其中eth0的信息删掉,并将eth1信息中的设备名改为eth0,重启系统,你看到的网卡就是eth0了。

方法二:由于系统默认的启动网卡是eth0,把eth2更改为eth0。调换下顺序。然后重启网络服务 :service network restart​

方法三:或者删掉其中所有的信息重启系统udev会帮你发现新的设备的。(我用此方法)

修改完之后,启动eth0网卡:ifconfig  eth0 up 

然后重启网络服务:service network restart 

二、

 写一半发现各种方法并没有解决问题,靠,整了半天了~

Guess you like

Origin www.cnblogs.com/wuzm/p/10972915.html