VirtualBox virtual machine network configuration

Reprinted from: http://www.douban.com/group/topic/15558388/

VirtualBox provides four network access modes, they are: 

1. NAT network address translation mode (NAT, Network Address Translation) 
2. Bridged Adapter bridge mode 
3, Internal internal network mode 
4, Host-only Adapter host  mode Explanation of

the first NAT mode 

NAT mode is the easiest to implement a virtual machine You can understand the way of surfing the Internet like this: all the data that Vhost accesses the network is provided by the host, vhost does not really exist in the network, and neither the host nor any machine in the network can view and access the existence of Vhost. 
The relationship between the virtual machine and the host: 
only one-way access, the virtual machine can access the host through the network, and the host cannot access the virtual machine through the network. 
The relationship between the virtual machine and other hosts on the network: 
only one-way access, the virtual machine can access other hosts on the network, and other hosts cannot access the virtual machine through the network.
The relationship between virtual machines and virtual machines: 
they cannot access each other, virtual machines and virtual machines are completely independent, and they 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 configured to use NAT, the first network card is connected to the private network 10.0.2.0, and the second network card is connected to the private network Network 10.0.3.0, etc. The default client ip (IP Address) is 10.0.2.15, the gateway (Gateway) is 10.0.2.2, and the domain name server (DNS) is 10.0.2.3, you can manually refer to this to modify. 
Advantages and disadvantages of NAT scheme: 
When the laptop is plugged into the network cable: The virtual machine can access the host, the virtual machine can access the Internet, and after port mapping is done (there is a description at the end), the host can access the services (such as databases) on the virtual machine. 
When the laptop is not plugged into the network cable: The "local connection" of the host has a red cross. The virtual machine can access the host, but the virtual machine cannot access the Internet. After port mapping, the host can access the services (such as databases) on the virtual machine. 

The second Bridged Adapter mode 
explanation:  The
bridge mode is my favorite mode, and at the same time, the analog degree is quite perfect. You can understand it this way, it is directly connected to the network by setting up a bridge through the host network card. Thus, it enables virtual machines to be assigned to separate IPs on a network, with all network functions exactly as real machines on the network. 
Relationship between virtual machine and host: 
They can access each other because the virtual machine has an independent IP in the real network segment. The host and virtual machine are in the same network segment and can access each other through their respective IPs. 
The relationship between the virtual machine and other hosts in the network: 
can access each other, also because the virtual machine has an independent IP in the real network segment, the virtual machine and all other hosts in the network are in the same network segment, and can access each other through their respective IPs. 
Virtual machine-to-virtual machine relationship: 
can access each other for the same reasons as above. 
IP: Generally assigned by DHCP, it is on the same network segment as the "local connection" IP of the host. The virtual machine can communicate with the host. 
When the laptop is plugged into the network cable: (if there is a DHCP server on the network) the host and the virtual machine will obtain an IP through DHCP respectively, and the two IPs are in the same network segment. The host and the virtual machine can be pinged, and the virtual machine can access the Internet. 
When the laptop is not plugged into the network cable: The host and the virtual machine cannot communicate. If the "local connection" of the host has a red cross, you cannot manually specify the IP. The virtual machine also cannot obtain an IP address through DHCP. After manually specifying the IP, it cannot communicate with the host because the host has no IP. 
At this time, the VirtualBox Host-Only Network card of the host has an ip, 192.168.56.1. Even if the virtual machine manually specifies the IP 192.168.56.*, it cannot ping the host. 

The third Internal mode 
explanation: 
Intranet mode, as the name implies, is the internal network mode, the virtual machine is completely disconnected from the external network, and only the internal network mode between the virtual machine and the virtual machine is realized. 
The relationship between virtual machines and hosts: 
they cannot access each other, they do not belong to the same network, and cannot access each other. 
The relationship between the virtual machine and other hosts in the network: 
cannot access each other for the same reasons as above. 
Relationship between virtual machines and virtual machines: 
They can access each other, provided that the two virtual machines have the same network name when setting the network. As shown in the configuration diagram above, the name is intnet. 
IP: VirtualBox's DHCP server will assign an IP to it. Generally, it gets 192.168.56.101, because it starts from 101, or you can manually specify 192.168.56.*. 
When the laptop is plugged into the network cable: The virtual machine can communicate with the host's VirtualBox Host-Only Network network card 
. This solution is not affected by whether the host's local connection (network card) has a red cross. 

Explanation of the fourth Host-only Adapter mode 

Host mode, which is a more complex mode, and requires a relatively solid basic knowledge of the network to play. It can be said that the functions implemented by the previous modes can be implemented through the settings of the virtual machine and the network card in this mode. 
We can understand that Vbox simulates a network card for virtual machines in the host, and all virtual machines are connected to this network card. We can set this network card to achieve Internet access and many other functions, such as (network card sharing, NIC bridging, etc.). 
The virtual machine and the host 
cannot access each other by default. The two parties do not belong to the same IP segment. The default IP segment of the host-only network card is 192.168.56.X and the subnet mask is 255.255.255.0. The subsequent virtual machines are also assigned to this segment. Through network card sharing, network card bridging, etc., virtual machines and hosts can access each other. 
The relationship between the virtual machine and the network host 
cannot access each other by default. The reason is the same as above. By setting, mutual access can be achieved. 
The relationship between virtual machines and virtual machines 
can access each other by default, and they are all in the same network segment. 
The virtual machine accesses the host using the IP of the host's VirtualBox Host-Only Network card: 192.168.56.1, regardless of whether the host's "local connection" has a red cross, it will always be connected. 
When the host accesses the virtual machine, it uses the IP of the virtual machine's network card 3: 192.168.56.101, regardless of whether the host's "local connection" has a red cross or not, it will always be connected. 
The virtual machine uses its own network card 2 to access the Internet. At this time, the host must be able to access the Internet through "local connection" (wireless network card does not work) 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326757137&siteId=291194637