VirtualBox Network Configuration

I have uninstalled the vmware software in my computer since I used virtualbox. Virtualbox is described as short and concise, and it is free, and the product is constantly being updated.

 

What I want to talk about today is the problem of network configuration after creating a virtual machine. In fact, other virtualization software will also involve these problems, but today I happen to have virtualbox on hand, so I will introduce it and practice it.

 

If we right-click a virtual machine on virtualbox and click on the network, there will be several settings as shown in the figure below.



 

When I searched for the exact meaning of each option on the Internet just now, I found that someone on the Internet has already summarized it very well. I think that if you summarize it yourself, it may not have this effect, so copy and paste it.

The original text comes from  http://www.douban.com/group/topic/15558388/  I adjusted the style on the basis, and added a little of my own.

 

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 

A NAT mode 
NAT mode is the easiest way to implement virtual machines to access the Internet. You can understand it like this: all data that Vhost accesses the network is provided by the host, vhost does not really exist in the network, the host and any network in the network. None of the machines can view and access the existence of the Vhost. 


1.1 The relationship between the virtual machine and the host
can only be accessed in one direction. The virtual machine can access the host through the network, but the host cannot access the virtual machine through the network. 


1.2 The relationship between the virtual machine and other hosts in the network
can only be accessed in one direction, the virtual machine can access other hosts in the network, and other hosts cannot access the virtual machine through the network.


1.3 The relationship between
virtual machines and virtual machines cannot be accessed from each other. Virtual machines and virtual machines are completely independent from each other, and cannot access each other through the network. And by default the ip address is the same.
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. 


1.4 Advantages and disadvantages
When the laptop is plugged into the network cable: The virtual machine can access the host, and the virtual machine can access the Internet. After port mapping (as explained 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 
, 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. 


2.1 The relationship between the virtual machine and the host
can access each other, because the virtual machine has an independent IP in the real network segment, the host and the virtual machine are in the same network segment, and they can access each other through their respective IPs. 


2.2 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. 


2.3 Virtual machines can access each other in a virtual machine relationship
for the same reasons as above. 

 

2.4 Advantages and disadvantages
IP: generally assigned by DHCP, and the IP of the host's "local connection" is on the same network segment. 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 
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. 


3.1 The relationship between the virtual machine and the host
cannot access each other. They do not belong to the same network and cannot access each other. 


3.2 The virtual machine and other hosts in the network
cannot access each other for the same reasons as above. 


3.3 The relationship between virtual machines and virtual machines
can access each other, provided that the two virtual machines set the same network name when setting the network. As shown in the configuration diagram above, the name is intnet. 

 

3.4 Advantages and Disadvantages
IP: The DHCP server of VirtualBox will assign an IP to it. Generally, it is 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.

You need to manually modify the ip yourself.

 

The fourth Host-only Adapter mode is 
the 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.).

 
4.1 The relationship between 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 is this network segment. Through network card sharing, network card bridging, etc., virtual machines and hosts can access each other. 


4.2 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. 


4.3 The relationship between virtual machines and virtual machines 
can access each other by default, and they are all in the same network segment. 

 

4.4 Advantages and Disadvantages
The virtual machine uses the IP of the VirtualBox Host-Only Network card of the host: 192.168.56.1 to access the host, regardless of whether the host "local connection" has a red cross or not, 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=326997413&siteId=291194637