VirtualBox commonly used network configuration is as follows:
Connection mode |
Host access to virtual machines |
Virtual Machine Access Host |
Virtual Machine Access Virtual machine |
Virtual Machine Access Extranet |
Description |
Network address translation (NAT) |
Not supported |
Support |
Not supported |
Support |
Default connection mode, virtual Ip,virtualbox Internal network conversion |
Bridge Adapter |
Support |
Support |
Support |
Support |
This is equivalent to the real computer, real IP, will occupy the real network IP resources |
Host-only (host-only) network |
Support |
Support |
Support |
Support |
This way using VirtualBox virtual network card, semi-real IP, through the sharing of Internet access can be achieved outside the network |
1. The default Nat method is relatively simple, but there are limitations, if you want the host to access the virtual machine, the virtual machine can access each other, you can not use this way
2. Bridging the network card is my personal preferred way, it has the highest degree of simulation, the equivalent of the real computer network, and no special configuration. This way, however, other people in the network can access your virtual machine and consume IP resources, which is not recommended if you want the virtual machine to be accessible only on your own computer.
3. Host-only (host-only) network, this way using VirtualBox virtual out of a network card (can be seen in the Internet connection), the virtual machine needs to configure a static IP to achieve and host mutual access, this way by default is not access to the external network, However, access to the extranet can be achieved through the host's Internet Connection Sharing
In this article we will explain the 3rd host-only how to achieve the perfect 4-way access
VirtualBox configuration, modify the network configuration as: Host only (host-only) network, select the VirtualBox virtual out of the network card, as follows:
Launch of CentOS virtual machine, no Internet access by default, no host
To modify the virtual machine network configuration, the Linux network configuration is in the/etc/sysconfig/network-scripts directory, and the CD used to view it using the LS command:
IFCFG-XX is the network configuration file, the following eth0 represents the NIC device name, each NIC a profile, using the VI ifcfg-eth0 command to modify the configuration
Add/Modify configuration as follows:
ipaddr=192.168.56.2
netmask=255.255.255.0
gateway=192.168.56.1
dns1=192.168.1.1
Bootproto=static
Description
IPADDR for IP address, netmask subnet mask, gateway for gateways, DNS1 for preferred dns,bootproto=static to use static IP
IP address set to follow the IP of the VirtualBox virtual network card in a network segment, the gateway is set to the IP of the virtual network card, as follows:
After Setup: Wq save and exit, and then use service network restart to restart the network service:
Now you can ping the host, as follows:
However, we can not access the external network, at this time we may use Internet Connection Sharing to enable VirtualBox virtual network card access to the extranet, configured as follows:
At this point the IP of the VirtualBox virtual network card will be changed to 192.168.137.1, we manually modified back to 192.168.56.1
Back to the virtual machine, Curl www.baidu.com, which has access to the extranet at this time:
VirtualBox in CentOS through Host-only way Virtual machine host mutual access, sharing Internet