Sunday, August 11, 2013

Fix lỗi không vào mạng khi clone centos với VMware

Cách 1:
At first, I checked the configuration of its NIC
$ ping www.google.com
ping: nuknown host www.google.com 
$ cat /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE="eth0"
HWADDR="00:50:56:B0:7F:24"
NM_CONTROLLED="no"
ONBOOT="yes"
TYPE=Ethernet
BOOTPROTO=static
IPADDR=192.168.20.174
NETMASK=255.255.255.0
DNS=168.126.63.1
DNS=168.126.63.2
GATEWAY=192.168.20.1
IPV6INIT=no

then, I restarted network of the VM.
$ service network restart
....
Bringing up interface eth0: Device eth0 does not seem to be present, defining initialization                                                [FAILED]



I found a post which include how to solve it. According to a post: http://aaronwalrath.wordpress.com/2011/02/26/cloned-red-hatcentosscientific-linux-virtual-machines-and-device-eth0-does-not-seem-to-be-present-message/, 

It was said like the following: 
"As it turns out there is a device manager for the Linux kernel named 'udev' which remembers the settings from the NIC of the virtual machine before it was cloned.  I was not familiar with udev because it was not installed in my previous Linux VM install, which were mainly CentOS 5."

I checked network device again.
$ ls /sys/class/net/
eth1   lo

It was wrong information. I intended that I added the NIC named "eth0". 

To solve this, I had to changed some information in /etc/udev/rules.d/70-persistent-net.rules file and in /etc/sysconfig/network-scripts/ifcfg-eth0.

1) Replace value of "ATTR{address} of "eth0 with the value of "eth1"
$ vi /etc/udev/rules.d/70-persistent-net.rules
.......
# PCI device 0x15ad:0x07b0 (vmxnet3) 
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}== "00:50:56:B0:7F:24", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
     -> wrong info.

# PCI device 0x15ad:0x07b0 (vmxnet3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:8e:27:fe", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"            -> right info. 


My /etc/udev/rules.d/70-persistent-net.rules file was modified. 
$ cat /etc/udev/rules.d/70-persistent-net.rules
....
# PCI device 0x15ad:0x07b0 (vmxnet3) 
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}== " 00:50:56:8e:27:fe", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

2) Change NIC's mac address with the same value of above case.
$ cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
HWADDR=" 00:50:56:8e:27:fe"
NM_CONTROLLED="no"
.....

3) Restart the VM.

The network of the VM worked as "eth0" after reboot.

Cách 2:
After clone the VM within Virtual box, I receive the error message “
Device eth0 does not seem to be present, delaying initialization.” when start the network service.
image
The /etc/sysconfigu/network-scripts/ifcfg-eth0 does exist. The issue is that the network device eth0 is non longer exist. The VM clone processes create the new device eth1.
The device file is at /sys/class/net.
ip link show
image
We can rename the device by using the up command.
ip link set eth1 name eth0
image
After the device being renamed, we can successfully bring up the network interface.