VirtualBox is a very good software, usually with the host there are 3 ways,bridged mode ,nat mode, Host-only way, the default way to install is NAT, But this way in the VirtualBox virtual machine has a disadvantage, is that the virtual machine can ping the host, the virtual machine can also access the external network through the host, but the host ping does not pass the virtual machine, people are very headache. Linux under the installation of a virtual machine would like to configure a server, and now all ping does not pass, How to play. Below, I slowly say my solution. Maybe a little stupid, but the perfect solution comes.
System environment:
Host: Ubuntu 14.04 32-bit
Virtual machine: VirtualBox 4.3.10 (downloaded directly from Ubuntu Software Center)
Installed virtual machine system: Centos 6.4 Character Interface (if you need to install a graphical interface, it is best to create a virtual machine when the memory is adjusted to more than 800M, the default is 500M, or the installation or character interface)
Install the Linux system, I do not say more here, I installed the CentOS 6.4 character interface system, or can not surf the internet, need a simple configuration under the DNS (VI/ETC/RESOLV.CONF), and network card (vi/etc/sysconfig/ Network-scripts/ifcfg-eth0), you can finish it.
Description: My virtual machine with two network card, network card 1 is used for NAT (for the Internet), Nic 2 is only-host (used to communicate with the host)
When the virtual machine is created by default, NIC 1 uses NAT mode, which does not have to be changed. We are mainly talking about how to ping the host and the virtual machine to each other.
1.virtualbox global Settings, CTRL + G
Add a adapter,vboxnet0 in the Network and set the ipv4:192.168.56.1 to cancel the DHCP server (we want to set the static IP).
After this step is completed, we can enter on the terminal: Ifconfig
This is what you just configured.
2.virtualbox Local Settings, CTRL + S
In the Network, attached to select Host-only Adapter,name select Vboxnet0.
Note that the NIC 1 and the NIC 2 MAC address are different and need to be configured correctly when configuring Eth0 and eth1 in the virtual machine.
3. Configure the Virtual machine network
How your virtual machine system is for Ubuntu system, the path of the configuration file is:/etc/network/interfaces. 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 for Centos6.4, I use eth0 as the network card 1 configuration file, using eth1 as the network card 2 configuration file.
If the file is not ifcfg-eth1 in the /etc/sysconfig/network-scripts/ directory, you can copy the Ifcfg-eth0.
If none, create a.
My virtual machine ifcfg-eth0 configuration file
My virtual machine ifcfg-eth1 configuration file
Need to note: device needs to change, HWADDR (hardware address) need to change, UUID does not change, bootproto need attention, a static, a dynamic, look at the changes. If you have more than one virtual machine, you just need to change the ifcfg-eth1 in each virtual machine in the ipaddr on the line, this range from 192.168.56.1 to 192.168.56.255, this can be set freely.
Finally, a command is executed on the virtual machine (different virtual machines may be different) to restart the network: Service network restart.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Simple configuration experience of VirtualBox virtual machine and host computer ping each other under Ubuntu