How to modify the network card after Linux virtual machine migration

  
 

In daily work or experiment, we often need to clone or migrate the virtual machine. After the migration, we must first set the virtual machine's network card to connect the virtual machine to the virtual machine. After migrating a Linux virtual machine, you will find that there is no more eth0 under the system, but it becomes eth1. After you restart the network service, you will be prompted to find the startup scripts for devices eth0 and eth1. Therefore, how to modify the network card after migrating the Linux virtual machine is very important.

First, why the network card name changes after migration
1.1. After you clone or migrate the Linux virtual machine, use ifconfig –a to view the network card information, you will find that only eth1, no eth0. Many Linux distributions use udev to dynamically manage device files and persist them based on device information. Udev will identify the network card during the system boot process, and record the mac address and the network card name in the udb rule script. For a new virtual machine, VMware will automatically generate a MAC address for the virtual machine's network card. When you clone or reinstall the virtual machine software, because you are using the information of the previous system virtual hard disk, and the system already has eth0 Information, for this new network card, udev will automatically name it eth1 (the principle of accumulation), so after your system starts, the network card you see using ifconfig is named eth1.

Second, how to modify the network card to obtain the network normally
2.1. View the network connection mode adopted by the virtual machine and the IP network segment allocated by the mode 2.2. Enter the directory /etc/sysconfig/network-scripts, you will find that Ifcfg-eth0 configuration file, if you directly modify the IP of the network segment, and then restart the network service, you will be prompted to report an error, eth0 the network card does not exist 2.3. Use ifconfig – a command to view, only eth1 network card information, then You can directly change eth0 to eth1, and change the MAC address to the MAC address of eth1. Then restart the network service eth1 to obtain the IP

. 3. How to change eth1 back to the original eth0
3.1. Modify the eth0 configuration file first. The MAC address is eth1's MAC address 3.2. Then enter the /etc/udev/rule.d/directory, open the 70-persistent-net.rules file, delete the eth0 information, and rename eth1 to eth0 3.3. Restart the computer
After using the ifconfig command to view eth0 correctly get the address, you can also connect normally through CRT

Copyright © Windows knowledge All Rights Reserved