In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is to share with you the content of an example analysis of four modes of VirtualBox virtual machine network setup. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
VirtualBox provides four network access modes, which are:
1. NAT Network address Translation Mode (NAT,Network Address Translation)
2. Bridged Adapter bridging mode
3. Internal internal network mode
4. Host-only Adapter host mode
The first NAT mode
NAT mode is the simplest way to achieve virtual machine access to the Internet. You can understand that all the data that Vhost accesses the network is provided by the host, the vhost does not really exist in the network, and the host and any machine in the network can not view and access the existence of Vhost.
Relationship between virtual machine and host:
Only one-way access, the virtual machine can access the host through the network, the host can not access the virtual machine through the network.
Relationship between virtual machines and other hosts in the network:
Only one-way access, the virtual machine can access other hosts in the network, other hosts can not access the virtual machine through the network.
The relationship between virtual machines and virtual machines:
Unable to access each other, virtual machines and virtual machines are completely independent 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 to use NAT, the first network card is connected to the private network 10.0.2.0, the second network card is connected to the private network 10.0.3.0, and so on. 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 it.
Advantages and disadvantages of NAT solution:
When the notebook is plugged into the network: the virtual machine can access the host, the virtual machine can access the Internet, after the port mapping (finally explained), the host can access the services on the virtual machine (such as database).
When the notebook is not plugged into the network cable: the "local connection" of the host has a red cross, the virtual machine can access the host, the virtual machine cannot access the Internet, and after port mapping, the host can access services on the virtual machine (such as database).
The second Bridged Adapter mode
Bridge mode is my favorite mode, at the same time, the degree of simulation is also quite perfect. You can understand it this way, it is through the host network card, set up a bridge, directly connected to the network. Therefore, it allows virtual machines to be assigned to a separate IP in a network, and all network functions are exactly the same as real machines in the network.
Relationship between virtual machine and host:
Can access each other because the virtual machine has a separate IP in the real network segment, and the host and the virtual machine are in the same network segment and can access each other through their own IP.
Virtual machine relationships with other hosts in 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 in the network, and can access each other through their own IP.
Virtual machine to virtual machine relationship:
Can visit each other for the same reason as above.
IP: it is generally assigned by DHCP, and the IP of the "local connection" of the host is the same network segment. The virtual machine can communicate with the host.
When the notebook has been plugged into the network cable: (if there is a DHCP server in the network) the host and the virtual machine respectively get an IP through the DHCP, and the two IP are in the same network segment. The host can communicate with the virtual machine through ping, 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. IP cannot be specified manually if the "local connection" of the host has a red cross. The virtual machine cannot get the IP address through DHCP, nor can it communicate with the host after manually specifying the IP, because the host does not have an IP.
At this time, the VirtualBox Host-Only Network network card of the host has ip, 192.168.56.1. The ping cannot host a virtual machine even if IP 192.168.56.slave is manually specified.
The third Internal mode
The internal network mode, as the name implies, is the internal network mode, which is completely disconnected from the external network, and only realizes the internal network mode between the virtual machines and the virtual machines.
Relationship between virtual machine and host:
Can not access each other, do not belong to the same network, can not access each other.
Relationship between virtual machines and other hosts in the network:
Cannot visit each other for the same reason as above.
Relationship between virtual machine and virtual machine:
Can access each other, provided that when setting up the network, the two virtual machines set the same network name. As in the configuration figure above, the name is intnet.
IP: VirtualBox's DHCP server assigns IP to it, and the general result is 192.168.56.101. Because it is divided from 101, 192.168.56.* can also be specified manually.
When the notebook is plugged into the network: the virtual machine can communicate with the host's VirtualBox Host-Only Network network card
This scheme is not affected by whether the host local connection (network card) has a red cross.
The fourth Host-only Adapter mode
Host mode, which is a more complex model, requires a relatively solid basic knowledge of the network to play. It can be said that the functions realized by the previous modes can be realized through the settings of virtual machines and network cards in this mode.
We can understand that Vbox simulates a network card dedicated to virtual machines in the host, and all virtual machines are connected to this network card. We can set up this network card to access the Internet and many other functions, such as (network card sharing, network card bridging, etc.).
Relationship between virtual machine and host
By default, they cannot access each other, and the two parties do not belong to the same IP segment. The default IP segment of the host-only Nic is 192.168.56.X with a subnet mask of 255.255.255.0, and the following virtual machines are all assigned to this segment. Through network card sharing, network card bridging and so on, virtual machines can access each other between hosts.
Relationship between virtual machine and network host
By default, you cannot access each other for the same reason as above. Through setting, you can access each other.
Relationship between virtual machine and virtual machine
They can access each other by default, and they are all on the same network segment.
The virtual machine accesses the host using the IP:192.168.56.1 of the host's VirtualBox Host-Only Network network card, regardless of whether the host "local connection" has a red cross or not.
The host accesses the virtual machine and uses the IP of the virtual machine's network card 3: 192.168.56.101, regardless of whether the host "local connection" has a red cross or not.
The virtual machine accesses the Internet using its own network card 2. At this time, the host computer should be able to access the Internet via "local connection" wired (wireless network card is not allowed).
Through the understanding of the above network models, we can use them flexibly to simulate any kind of network environment we want.
For example, I want to simulate a host to monitor the network environment of a local area network.
First of all, I started two virtual machines vhost1 and vhost2, of course, if the hardware allows, I can also add vhost3, vhost4 …
All the vhost I set to internat intranet mode, the network name is intnal, the gateway is 192.168.56.100, which means surfing the Internet through the 192.168.56.100 network card. Among them, one vhost1 is set to dual network card, one is intranet mode (192.168.56.100), and the other is bridge mode (192.168.1.101). Two network cards
Set up double network cards to share the Internet.
There is a local area network between the virtual machines, in which a virtual machine vhost1 is connected to the external network, and all the virtual machines in the local area network are connected to the external network through vhost1. In this way, vhost1 can monitor the Internet access of the entire virtual machine LAN.
NAT sets Port Mappin
You can set up a virtual machine service (such as a WEB service) by using the command line tool VboxManage proxy. You need to know which port the virtual machine services use, and then decide which port to use on the host (usually but not always want the virtual machine and the host to use the same port). Providing a service on the host requires the use of a port, and you can use any port on the host that is not ready to provide the service. An example of how to set up a new NAT to connect to a 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
Note: 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 it freely and forward port 22 of the virtual machine to port 2222 of the host through the above three commands.
For example, I installed an apache2 server on the virtual machine debian, using port 80, which is mapped to port 80 of the host. Use the following command.
'C:\ Program Files\ innotek VirtualBox\ VBoxManage.exe' setextradata 'debian'' VBoxInternal/Devices/pcnet/0/LUN#0/Config/huzhangsheng/Protocol' TCP
'C:\ Program Files\ innotek VirtualBox\ VBoxManage.exe' setextradata 'debian'' VBoxInternal/Devices/pcnet/0/LUN#0/Config/huzhangsheng/GuestPort' 80
'C:\ Program Files\ innotek VirtualBox\ VBoxManage.exe' setextradata 'debian'' VBoxInternal/Devices/pcnet/0/LUN#0/Config/huzhangsheng/HostPort' 80
Note: for the setting to take effect, please turn off VirtualBox and run the virtual machine again. I installed VirtualBox on winxp, installed debian 4.02r in the virtual machine, the virtual machine name is debian, and installed apache2 php5 mysql-server, browsed http://localhost on the host with IE, and successfully forwarded it to the apache2 web server of virtual machine debian
I feel uncomfortable by using port mapping, which is not as fast as direct bridging. Now, in most cases, it is no problem to connect to the network. Port mapping also needs to open an additional service in both the host and the virtual machine.
The Network configuration page has four scenarios:
1:NAT Network address Translation (Network Address Translation)
2:Birdged Network bridging
3:Internal Network internal network (can be between virtual machines and virtual machines)
4:Host-Only only communicates with hosts (probably)
After installing VirtualBox2.2, the host has a "VirtualBox Host-Only Network" local network card.
My network environment:
Host:
System: xp
"Local connection" IP: because it is a notebook, often change work network environment, are assigned through DHCP, sometimes there is no network, "local connection" has a red cross (has an impact on host and virtual machine communication).
"VirtualBox Host-Only Network network card" IP:192.168.56.1, because VirtualBox's DHCP server IP is 192.168.56.100, which is on the same network segment.
Virtual machine: to be able to communicate with the host, to be able to access the Internet (do not need to be accessed by the Internet).
System: win2003
Network card 1, network card 2, network card 3 talk about the configuration of each network card
Configuration of each network card
Network card 1: use NAT scheme
IP:10.0.2.15
Gateway: 10.0.2.2
DNS:10.0.2.3
Why is it configured in this way? Because in the help of VirtualBox, there is the following paragraph:
Multiple network cards of a virtual machine can be set to use NAT, the first network card is connected to the private network 10.0.2.0, the second network card is connected to the private network 10.0.3.0, and so on. 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 it.
Advantages and disadvantages of NAT solution:
When the notebook is plugged into the network: the virtual machine can access the host, the virtual machine can access the Internet, after the port mapping (finally explained), the host can access the services on the virtual machine (such as database).
When the notebook is not plugged into the network cable: the "local connection" of the host has a red cross, the virtual machine can access the host, the virtual machine cannot access the Internet, and after port mapping, the host can access services on the virtual machine (such as database).
Network card 2: use Birdged Network scheme
IP: it is generally assigned by DHCP, and the IP of the "local connection" of the host is the same network segment. The virtual machine can communicate with the host.
When the notebook has been plugged into the network cable: (if there is a DHCP server in the network) the host and the virtual machine respectively get an IP through the DHCP, and the two IP are in the same network segment. The host can communicate with the virtual machine through ping, 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. IP cannot be specified manually if the "local connection" of the host has a red cross. The virtual machine cannot get the IP address through DHCP, nor can it communicate with the host after manually specifying the IP, because the host does not have an IP.
At this time, the VirtualBox Host-Only Network network card of the host has ip, 192.168.56.1. The ping cannot host a virtual machine even if IP 192.168.56.slave is manually specified.
Network card 3: use Host-Only scheme
Ip: VirtualBox's DHCP server assigns IP to it, and the general result is 192.168.56.101. Because it is divided from 101, 192.168.56.* can also be specified manually.
When the notebook is plugged into the network: the virtual machine can communicate with the host's VirtualBox Host-Only Network network card
When the notebook is not plugged in, the virtual machine can communicate with the host's VirtualBox Host-Only Network network card.
This scheme is not affected by whether the host local connection (network card) has a red cross.
For the above three schemes, you can right-click the icons of the two small TVs at the bottom of the virtual machine window to quickly switch. Meet a variety of network environments.
As for the Internal Network plan, I didn't try it either.
Summary of the above three schemes
The following two scenarios are enabled at the same time:
Network card 2: use Birdged Network scheme
Network card 3: use Host-Only scheme
The virtual machine accesses the host using the IP:192.168.56.1 of the host's VirtualBox Host-Only Network network card, regardless of whether the host "local connection" has a red cross or not.
The host accesses the virtual machine and uses the IP of the virtual machine's network card 3: 192.168.56.101, regardless of whether the host "local connection" has a red cross or not.
The virtual machine accesses the Internet using its own network card 2. At this time, the host computer should be able to access the Internet via "local connection" wired (wireless network card is not allowed).
The four modes of VirtualBox virtual machine network settings just look dizzy, but as long as you understand the effects of the four modes, you can use them flexibly.
Thank you for reading! This is the end of the article on "sample Analysis of four modes of VirtualBox Virtual Machine Network Settings". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.