Install centos network configuration on virtualbox Virtual Machine

Source: Internet
Author: User
Tags domain name server

Recently, hadoop was developed on Linux, So I installed a virtualbox Virtual Machine and installed a centos system on the virtual machine. Linux is installed, but network configuration is another headache. I mainly want to allow the host machine and virtual machine to access each other.

Then I went to Baidu and configured it step by step based on Baidu's results.

After virtualbox is installed, it will install a virtual Nic on the host machine,

  

Double-click it to view details and information.

I used the host-only method to configure the network on a virtual machine. Of course, the bridging method can also be used. There are many differences between them on the Internet. The virtual machine uses this virtual network card as the gateway.

After entering the centos system, there are three files to be configured:

1. Modify the IP address

Use the command VI/etc/sysconfig/newwork-scripts/ifcfg-eth0 to modify the file as follows

Device = "eth0"
Bootproto = "static". Here, the static IP address is used.
Hwaddr = "08: 00: 27: 0C: 33: 8f"
Nm_controlled = "yes"
Onboot = "yes" is set to auto start
Type = "Ethernet"
UUID = "f4adafbc-322d-4dc8-b549-4291f1c04f01"
Ipaddr = 192.168.137.101 sets the IP address of the virtual machine. The IP address must be in the same CIDR block as the host machine, but cannot be renamed.
Netmask = 255.255.255.0 set the subnet mask
# Gateway = 192.168.137.1 set the gateway, that is

2. Modify the Gateway

Run VI/etc/sysconfig/network to modify the file content as follows:

Networking = Yes
Hostname = localhost. localdomain
Gateway = 192.168.137.1 set the gateway here, that is, the IP address of the virtual network card

3. Modify DNS

Run VI/ECT/resolv. conf to modify the file as follows:

Add a Domain Name Server for nameserver 192.168.137.1

 

Restart the network service and run the service network restart command.

 

First, complete the configuration according to this step. Ping the VM on the host machine. No problem. However, ping the host machine and gateway on the virtual machine fails, let alone ping the internet. The problem is as follows:

When you ping the host machine and the gateway, the system does not prompt that the ping fails, but cannot receive the peer information. Packets: Sent = 4, received = 0, lost = 4 (100% loss ). The result of Ping www.baidu.com is invalid host name. This problem plagued me for a whole day and Baidu could not find the result. I know the problem must be the IP Address Configuration. After Baidu failed this evening, I thought of the virtual network card. I used the above method to configure it, the virtual network card is used as the gateway, but the virtual network card is not configured at all, it has nothing to do with the network card on my computer, it is certainly not good to use it directly. Later, I thought we could use broadband to share Wireless WiFi. Why can't we share the broadband connection with that virtual network card? Try again immediately. After the sharing is started, the IP address of the virtual network card changes again, and then configure the network information again in centos according to the above steps. The result is actually OK, the problem that plagued me for a day or two finally solved.

Ping the host machine. OK.

Ping www.baidu.com is also OK.

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.