VirtualBox is a free and open source virtual machine that many friends often use for virtual experimentation. VirtualBox can run multiple virtual machines on the same computer, and these virtual machines run different operating systems. The following small series on how to share the VirtualBox how to do network settings, what is the case for what mode
There are four different patterns in VirtualBox:
1, NAT network address translation mode (nat,network adress translation)
2, bridged Adapter bridge mode
3. Internal Internal network mode
4, host-only Adapter host mode
The first NAT mode
Nat mode is the simplest way to implement the virtual machine, you can understand that: Vhost access to the network of all the data are provided by the host, Vhost is not true in the network, the host and the network of any machine can not view and access to the existence of vhost.
Virtual machine and host relationship:
Only one-way access, the virtual machine can be accessed through the network to the host, the host can not access the virtual machine over the network.
Relationship between virtual machines and other hosts in the network:
Only one-way access, the virtual machine can access other hosts on the network, other hosts cannot access the virtual machine over the network.
The relationship between virtual machines and virtual machines:
Inaccessible to each other, virtual machines and virtual machines are completely independent of each other and cannot access each other through the network.
ip:10.0.2.15
Gateway: 10.0.2.2
dns:10.0.2.3
Multiple network cards of a virtual machine can be set up using NAT, the first network card is connected to the private network 10.0.2.0, the second network card is connected to the private networks 10.0.3.0, and so on. The default client IP address is 10.0.2.15, the gateway is 10.0.2.2, and the domain name server (DNS) is 10.0.2.3, which can be manually referenced for modification.
NAT Scheme pros and Cons:
When the laptop is plugged in, the virtual machine can access the host, the virtual machine can access the Internet, and after the port mapping (and finally the instructions), the host can access the services on the virtual machine (such as the database).
Notebook is not plugged in: the host "local connection" has a red fork, the virtual machine can access the host, the virtual machine can not access the Internet, after the port mapping, the host can access the services on the virtual machine (such as database)
The second type of bridged adapter model
Explain:
Network Bridge mode is my favorite use of a pattern, at the same time, the simulation is also quite perfect. You can understand this, it is through the host network card, erected a bridge, directly connected to the network. Therefore, it allows the virtual function to be assigned to a single network of independent IP, all network functions are completely the same as the real machine in the network.
Virtual machine and host relationship:
can access each other, because the virtual machine has a separate IP in the real network segment, the host and the virtual machine are in the same network segment, each other can access each other through their respective IP.
Virtual machines in other host relationships on the network:
can access each other, also because the virtual machine has a separate IP in the real network segment, the virtual machine is in the same network segment as all other hosts of the network, and each other can access each other through their respective IP.
Virtual machine to virtual machine relationship:
Can visit each other for the same reason.
IP: DHCP is generally allocated, and the host's "Local Connection" IP is the same network segment. The virtual machine can communicate with the host.
When the notebook is plugged in: (If there is a DHCP server in the network) the host and the virtual opportunity through DHCP to get an IP, the two IP in the same network segment. The host and the virtual machine can ping, the virtual machine can be on the Internet.
The laptop is not plugged in: the host and the virtual machine cannot communicate. The host's "Local Area Connection" has a red fork, so you cannot specify IP manually. The virtual machine also cannot obtain the IP address through the DHCP, after manually specifies the IP, also cannot communicate with the host, because the host does not have the IP.
At this time the host VirtualBox host-only network network card is IP, 192.168.56.1. Virtual machine Even if the manual specified IP 192.168.56.*, also ping can not host.
The third type of internal model
Explain:
Intranet mode, as the name implies is the internal network mode, virtual machine and external network completely disconnected, only the virtual machine in the virtual machine between the internal network mode.
Virtual machine and host relationship:
Cannot access each other, not belong to the same network, and cannot access each other.
Virtual machine relationships with other hosts on the network:
Cannot visit each other for reasons ditto.
Virtual machine and virtual machine relationship:
can access each other, provided that the two virtual machines set the same network name when the network is set up. As in the configuration diagram above, the name is intnet.
Ip:virtualbox's DHCP server assigns IP to it, typically 192.168.56.101, because it is from 101, or you can specify 192.168.56.* manually.
When a network cable is plugged in: the virtual machine can communicate with the host's VirtualBox host-only network NIC
This scenario is not affected by a host local connection (NIC) that has a red fork.
The fourth type of HOST-ONLY adapter model
Explain:
Host mode, this is a more complex mode, need to have a more solid network basic knowledge to play the turn. It can be said that the previous several modes of implementation of the function, in this mode, through the virtual machine and network card settings can be implemented.
We can understand that vbox in the host to simulate a dedicated virtual machine to use the network card, all virtual machines are connected to the network card, we can set up this card to achieve the Internet and many other functions, such as (network card sharing, network card bridge, etc.).
Virtual machine and host relationships
The default is not to access each other, the two sides do not belong to the same IP segment, the HOST-ONLY network card default IP field 192.168.56.X subnet mask is 255.255 255.0, the following virtual machine is assigned to the network segment. Through the network card sharing, network card bridge and so on, you can realize the virtual machine in the host mutual access.
Virtual machine and Network host relationship
The default is not to access each other, for the same reason, through settings, you can achieve mutual access.
Virtual machine and virtual machine relationship
The default is to access each other, both in one network segment.
Virtual Machine Access host is the host of the VirtualBox host-only Network network card ip:192.168.56.1, regardless of host "local connection" there is no red fork, forever pass.
Host access to the virtual machine, with the virtual machine's network card 3 ip:192.168.56.101, regardless of host "local connection" there is no red fork, forever pass.
Virtual machine access to the Internet, with its own network card 2, when the host to be able to through the "local connection" wired Internet, (wireless network card does not work)
Through the understanding of the above several network modes, we can use flexibly, simulate to build out any kind of network environment that we want.
For example, I want to simulate a host, monitor a LAN network environment of the internet situation.
First I opened two virtual machines vhost1 and Vhost2, of course, if the hardware allowed, I can also add vhost3, Vhost4 ...
All the vhost I have set into Internat intranet mode, the network name is intnal, the gateway is 192.168.56.100, which means to access the Internet through the 192.168.56.100 network card. One of the vhost1 I set for the dual network card, one for the intranet mode (192.168.56.100), one for the bridge mode (192.168.1.101). Two network cards set up dual network card sharing internet
Between virtual machines for the LAN, which has a virtual machine vhost1 through the extranet, all the virtual machines in the LAN through the VHOST1 to achieve the external network. This allows Vhost1 to monitor the entire virtual machine LAN access.
NAT Set Port Mappings
http://huzhangsheng.blog.163.com/blog/static/34787784200802801435931/
You can set up a service for a virtual machine (such as a WEB service) by using the command-line tool to vboxmanage the proxy. You need to know which port the service of the virtual machine uses, and then decide which port to use on the host (usually but not always want the virtual machines and hosts to use the same port). Providing a service on the host requires a port, and you can use any port on the host that is not ready to provide the service. How to set up a new NAT example to connect to an SSH server on a virtual machine requires the following three commands:
Vboxmanage setextradata "Linux Guest"
"Vboxinternal/devices/pcnet/0/lun#0/config/guestssh/protocol" TCP
Vboxmanage setextradata "Linux Guest"
"Vboxinternal/devices/pcnet/0/lun#0/config/guestssh/guestport" 22
Vboxmanage setextradata "Linux Guest"
"Vboxinternal/devices/pcnet/0/lun#0/config/guestssh/hostport" 2222
Description: Vboxmanage is a command-line program, please check your VirtualBox installation directory, "Linux Guest" is the virtual host name. Guestssh is a custom name, and you can set the three commands above to forward the 22 ports of the virtual machine to the 2222 port of the host.
For example, I installed the APACHE2 server on the virtual machine Debian, using port 80 to map to 80 ports on the host. Use the following command.
"C:Program Filesinnotek VirtualBoxVBoxManage.exe" Setextradata "Debian"
"Vboxinternal/devices/pcnet/0/lun#0/config/huzhangsheng/protocol" TCP
"C:Program Filesinnotek VirtualBoxVBoxManage.exe" Setextradata "Debian"
"Vboxinternal/devices/pcnet/0/lun#0/config/huzhangsheng/guestport" 80
"C:Program Filesinnotek VirtualBoxVBoxManage.exe" Setextradata "Debian"
"Vboxinternal/devices/pcnet/0/lun#0/config/huzhangsheng/hostport" 80
Note: For the setting to take effect, turn off VirtualBox and run the virtual machine, install VirtualBox on WinXP, install Debian 4.02r in the virtual machine, the virtual machine name is Debian, and install the apache2 php5 mysql- Server, on the host using IE browsing http://localhost, successfully forwarded to the virtual machine Debian apache2 Web server