Linux replication, network error

Source: Internet
Author: User

I copied the Linux virtual machine can not access the Internet, I use the ifconfig command query found only eth1 and lo devices, no eth0. So I did a search on Google, "VMware cloning or replicating a Linux virtual machine after eth0 can't find a solution"

Description of the phenomenon:

Recently installed the virtual machine system is Centos, in order to later use convenient to clone or replicate the virtual machine. When using the cloned virtual machine, found that the original network card in the basic system eth0 to the new system is not, using ifconfig-a will find only eth1. Because the basic system network-related configuration is based on eth0, eth1 No network-related configuration, at this time to normal the network in the virtual machine, only add eth1 network configuration, so every time to modify the network card configuration in the long Linux system testing is not convenient. Further, if you continue to clone or replicate a new virtual machine based on this cloned virtual machine, the network card's identity is automatically added 1 each time (the second clone becomes eth2), and DMESG shows that the kernel only recognizes the NIC Eth0.

Cause Analysis:

Many Linux distribution use Udev to dynamically manage device files and name them based on the device's information. For example, in Debian Etch, Udev identifies the network card during system boot and records the MAC address and network card name in Udev's rules script. VMware automatically generates the MAC address of the virtual machine. In this way, because the virtual machine of the basic system has recorded that the virtual machine's network card MAC address corresponds to the NIC Eth0, in the cloned virtual machine due to the MAC address changes, Udev will automatically correspond to the Mac to the NIC Eth1. And so on, Udev will record all identified Mac and network card name relationship, so each clone network card name will automatically add 1, but in fact, kernel only to recognize a network card, the network configuration associated with the NIC name has not changed any.

Solution:

Network search found under the Debian Etch, Udev saves the Mac and Nic name correspondence in/etc/udev/rules.d/z25_persistent-net.rules, in the cloned virtual machine as long as the deletion and name= "eth0" Related lines and restart the system. For example, delete the following two lines in the Debian etch:
# PCI Device 0x1022:0x2000 (pcnet32) subsystem== "NET", drivers== "? *", attrs{address}== "00:0c:29:4c:46:01", name= "eth0"

Under my fedora9, modify the 70-persistent-net.rules file deletion under/ETC/UDEV/RULES.D

# advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE] (rule written by Anaconda)
subsystem== "NET", action== "Add", drivers== "? *", attr{address}== "00:0c:29:ad:06:2a", attr{type}== "1", kernel== "eth*" , name= "Eth0"

Then the eth1 corresponding to which line of "eth1" modified to "eth0" can be.

Another way is: to delete the contents of the inside, and then restart, the system will rediscover the NIC hardware, re-generate the file.

Here is one thing to add:

It is also the same with the following command to implement the second method:

Cd/etc/udev/rules.d
sudo rm *-net.rules//Delete
sudo reboot

I use the above method, and then use Ifconfig view, did find the eth0 device, but no IP address.

Next, use the Ifconfig command to set the IP address, and some of the relevant commands are:

Ifconfig eth0 192.168.0.10 will take the default subnet mask
Ifconfig eth0 192.168.0.10 netmask 255.255.255.252 (manually defined subnet mask) (invalid after reboot)

Ifconfig eth0 Down (disable NIC)
Ifconfig eth0 up (activate NIC)

Service Network Restart (Restart Network Service)
/etc/rc.d/init.d/network Restart (IBID.)

I use ifconfig eth0 192.168.0.10 netmask 255.255.255.252 to set up IP, and then perform service network restart.

System prompt: Eth0 existing MAC address and system to set the mismatch, set the MAC address failed.

Because the NIC configuration information is saved in the/etc/sysconfig/network-scripts/ifcfg-eth0 configuration file, go and see it.

The basic contents of the document are as follows:

Device=eth0 (which net card)

Onboot=yes
bootproto=static (static IP status setting)

BOOTPROTO=DHCP (DHCP Fetch)

ipaddr=192.168.1.8 (static IP address)
netmask=255.255.255.0
gateway=192.168.1.1 (Gateway)

Hwaddr=00:0c:29:96:38:f8 (Modify MAC address) (permanently active)

I have deleted the contents of the document, leaving only

Device=eth0

Bootproto=dhcp

Hwaddr=00:0c:29:96:38:f8 (Modify the system that is indicated in the hint message to expect to be assigned to Eth0 's Mac)

Onboot=yes
After you restart Linux, you can surf the internet normally.

Linux replication, network error

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.