In fact, the network of such related articles a lot, I just want to combine their actual situation, my experience to write down to those who need it. Host: Windows XP virtual machine: Ubuntu 10.10 virtualbox:4.0.2
After the virtual machine is installed, by default, it is through the network connection of NAT, in which case, the virtual machine can go to the internet normally, but cannot communicate with host. The effect we want is that the physical machine can access the virtual machine via IP, while the virtual machine can access the Internet.
What we need to do is to enable the second network interface and change the interface to hostonly mode. The purpose of this interface is to communicate with the host. After the VBox is installed, the physical host system automatically generates a network adapter (VirtualBox host-only Network), which, by default, is 192.168.56.1, and remember to make sure that the NIC is set to Enabled.
After the virtual machine is started, there will be two network cards, one is the original network card, IP address under normal circumstances will be 10.0.2.x, this network card is connected with the host through NAT, mainly used to access the network, in addition, there will be a new network card, the IP set to 192.168.56.x, The gateway is set to 192.168.56.1, the purpose of which is to communicate with the physical machine.
After some setup, the virtual machine should be able to access the physical machine via IP, and can access the network at the same time. Note that in this configuration, if the physical host is in a local area network, then other hosts on the LAN cannot be accessed via IP.
If other hosts in the local area network are required to access the virtual machine, the network connection of the virtual machine needs to be changed from host to bridged Adapter and the actual physical network interface on the physical host is selected as the Access interface. If the network is IP via DHCP, the virtual machine can obtain an IP address that is equal to the physical machine, as if a new physical machine is plugged into the LAN. If you do not have DHCP, then manually set an equivalent IP address to the physical host, you can get the same effect.