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.

Related Posts:

  • File Permission trong Linux Một trong những thành phần chính của hệ điều hành Linux là hệ thống quyền hạn truy cập (permission) áp dụng cho mọi đối tượng (file, thư mục, link…). Hệ thống này đóng 1 vai trò quan trọng trong việc đem lại mức an ninh cao … Read More
  • Các lệnh về fileXóa file và thư mục: -Xóa file: $ rm {name file} $ rm -f {name file}:không hỏi lại có muốn xóa không? -Xóa thư mục: $ rm -rf {name folder} Trong đó -r : Attempt to remove the file hierarchy rooted in each file argument i.… Read More
  • Hiển thị tiến trình trong hệ thống Linux Một trong những công việc cần thiết khi quản trị hệ thống Linux đó là kiểm soát các tiến trình hiện đang chạy. Khi đã biết được những tiến trình nào đang chạy bạn có thể tắt những tiến trình gây giảm tốc độ của hệ thống. Ng… Read More
  • Cấp quyền thực thi với sudoMột trong những câu hỏi thường gặp nhất của người mới sử dụng Ubuntu là về sudo. Cơ chế bảo mật này được kích hoạt mặc định trong Ubuntu và mang lại nhiều ưu điểm hơn cơ chế chuyển sang người dùng khác bằng su truyền thống… Read More
  • Clear memory linuxLệnh dùng clear memory cho linux. sync; echo 3 > /proc/sys/vm/drop_caches free -m … Read More