VirtualBox Virtual machine installation CentOS Network configuration _virtualbox

Source: Internet
Author: User
Tags domain name server centos

The recent contact with Hadoop needs to be developed on Linux, so I've installed a VirtualBox virtual machine that installs a CentOS system on the virtual machine. The Linux system is installed, but the network configuration is another headache. I want the host and virtual machines to be able to access each other primarily.

Then I will Baidu a bit, according to the results of Baidu step-by-step configuration.

After installing VirtualBox, it installs a virtual NIC on the host computer, as shown

Double-click it to see the details, as shown in the figure

Configure the network on the virtual machine I am using the host-only way, of course, can also use bridging the way, as for their differences, online a lot. The virtual machine mainly uses this virtual network card as the gateway.

After entering the CentOS system, there are mainly three files required to be configured:

1. Modify IP Address

Use the command Vi/etc/sysconfig/network-scripts/ifcfg-eth0 to modify the contents of this file as follows:

Device= "Eth0"
bootproto= static IP instead
Hwaddr= "08:00:27:0c:33:8f"
Nm_controlled= "Yes"
onboot= "Yes" set to start automatically
Type= "Ethernet"
Uuid= "F4adafbc-322d-4dc8-b549-4291f1c04f01"
ipaddr=192.168.137.101 set the IP address of the virtual machine to the host in a network segment, but cannot duplicate the name
netmask=255.255.255.0 Set Subnet mask
#GATEWAY =192.168.137.1 Set the gateway, which is

2, modify the Gateway

Using the command: Vi/etc/sysconfig/network Modify the contents of the file as follows:

Networking=yes
Hostname=localhost.localdomain
gateway=192.168.137.1 here to set the gateway, which is the IP of the virtual network card

3. Modify DNS

Using the command: Vi/ect/resolv.conf Modify the contents of the file as follows:

NameServer 192.168.137.1 Add a domain name server

Finally restart the Network service is OK, using the command service network restart.

To begin, I follow this step to complete the configuration. Ping the virtual machine on the host, no problem can ping. However, it is problematic to ping host and gateway on the virtual machine, let alone ping the Extranet. The questions are as follows:

Ping host and Gateway, there is no hint ping impassability, just receive the information of the other side, packets:sent = 4,received = 0,lost = 4 (100% loss). Ping www.baidu.com The result is an invalid host name. This problem has plagued me for a whole day, Baidu can not find the results. I know the problem is definitely out of the IP configuration above, in this evening Baidu no fruit, I thought of the virtual network card, I use the above method configuration, is using the virtual network card as a gateway, but the virtual network card is not configured, it and my Computer network card does not have a relationship, directly to use it is certainly not. Then I thought we could use broadband to share Wi-Fi, so why not share the broadband connection to that virtual network card? Try now, start sharing, the IP of the virtual NIC changed again, and then centos in accordance with the above steps to configure the network information, the results can really, trouble me a day or two problem finally solved.

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.