Ubuntu VirtualBox Virtual Machine and host machine ping each other simple configuration experience, ubuntuvirtualbox

Source: Internet
Author: User

Ubuntu VirtualBox Virtual Machine and host machine ping each other simple configuration experience, ubuntuvirtualbox

Virtualbox is a very good software. There are usually three methods between virtualbox and the host,Bridged Mode,NAT mode, host-onlyThe default method of installation is NAT. However, this method has a disadvantage in virtualbox virtual machine, that is, the virtual machine can ping the host, and the virtual machine can also access the Internet through the host, however, it is a headache to ping the VM from the host. in linux, if you want to configure a server in a virtual machine, you cannot ping it now. How can you do this. next, let me talk about my solution. it may be a bit stupid, but it can be solved perfectly.


System Environment:

HOST: ubuntu 14.04 32-bit

Virtual Machine: virtualbox 4.3.10 (downloaded directly from the ubuntu Software Center)

Installed Virtual Machine System: Centos 6.4-character interface (if you need to install a graphical interface, you 'd better adjust the memory to 500 mb or more when creating a virtual machine. The default value is mb. Otherwise, the installation or character interface is used)


I will not talk about installing the linux system here. After installing the Centos 6.4-character interface system, I still cannot access the Internet. You need to configure DNS (vi/etc/resolv. conf), and the NIC (vi/etc/sysconfig/network-scripts/ifcfg-eth0), you can finish.


Note: my VM uses two NICs. Nic 1 is used for NAT (used for surfing the Internet) and nic 2 is used for only-host (used to communicate with the host)



When a virtual machine is created by default, Nic 1 uses the NAT mode, which does not need to be changed. We mainly talk about how to ping the host and virtual machine.

1. virtualbox global settings, ctrl + G

Add an adapter in the Network, vboxnet0, set ipv4: 192.168.56.1, and cancel DHCP server (we need to set static IP ).


After this step is completed, we can enter: ifconfig on the terminal

This is what we just configured.


2. virtualbox local settings, ctrl + S

In Network, select Host-only Adapter for attached to and vboxnet0.

Note that Nic 1 and nic 2 have different MAC addresses. You must configure eth0 and eth1.


3. Configure the Virtual Machine Network

The path of the configuration file is/etc/network/interfaces. The configuration content is as follows:

Auto eth0
Iface eth0 inet static
Address 192.168.56.99
Netmask 255.255.255.0
Gateway 192.168.56.1
Nameserver 8.8.8.8


My current Virtual Machine System is Centos6.4. I use eth0 as the configuration file for Nic 1 and eth1 as the configuration file for Nic 2.

If the/etc/sysconfig/network-scripts/directory has no ifcfg-eth1 for this file, you can copy a ifcfg-eth0.

If none of them exist, create one.

My virtual machine ifcfg-eth0 Profile


My virtual machine ifcfg-eth1 Profile


Note: The DEVICE needs to be changed, the HWADDR (hardware address) needs to be changed, and the UUID has not been changed. The BOOTPROTO needs to be noted that it is static and dynamic. Let's look at the modification. if you have multiple virtual machines, you just need to change the ipaddr in the ifcfg-eth1 of each virtual machine, this range from 192.168.56.1 to 192.168.56.255, this can be set by yourself.


Finally, execute a command on the Virtual Machine (different virtual machines may be different) to restart the network: service network restart.



Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.