Analysis and Setup of virtualbox Virtual Machine network environment-Nat, bridging, host-only, internal, port ing

Source: Internet
Author: User

This document uses virtualbox as an example.





I. Nat Mode


Features:

1. If the host can access the Internet, the VM can access the Internet.

2. Ping is not allowed between virtual machines.

3. the VM can ping the host (in this case, ping the gateway of the VM, that is, ping the host)

4. The host cannot ping the VM.


Application scenarios:

Virtual machines only require Internet access, without other special requirements, to meet the most general needs


Configuration method:

Select Network Address Translation (NAT) as the connection method)

Advanced-control chip selection pcnet-fast III

Advanced-reject in Mixed Mode

Advanced-access network cable √

(Virtual Machine IP address automatically obtained)


IP style:

IP 10.0.2.15

Gateway 10.0.2.2

Note that the gateway here may be the same value in different virtual machines, but it belongs to different NAT engines. Therefore, in fact, different virtual machines use different gateways.


Principle:

Requests from virtual machines are sent to the NAT engine, which uses the host for external network access, and the returned packets are then sent to the Virtual Machine by the NAT engine.






Ii. bridged adapter mode (Bridging Mode)


Features:

1. If the host can access the Internet, the VM can access the Internet.

2. Ping between virtual machines

3. the VM can ping the host.

4. The host can ping the VM.

The preceding points are based on the premise that the host can access the Internet.

5. If the host cannot access the Internet, all 1-4 features are unavailable.


Application scenarios:

The virtual machine requires Internet access, and the virtual machine completely simulates a physical machine


Configuration method:

Select bridging network card for connection mode

Interface Name selection (If your laptop has a wireless network card and a wired network card, you need to select according to the current Internet access method)

Advanced-control chip selection pcnet-fast III

Advanced-reject in Mixed Mode

Advanced-access network cable √

(Virtual Machine IP address automatically obtained)


IP style:

The IP address and the local IP address are in the same network segment.

The gateway is the same as the local gateway.


Principle:

Establish a bridge through the host Nic and connect it directly to the network. It allows virtual machines to be allocated to independent IP addresses in a network. All network functions are completely consistent

The real machines on the network are the same.

(Virtual machines obtain IP addresses through the DHCP service in the network where the host is located. Therefore, the two are completely independent, but the fact is that virtual machines do not

If there is an independent hardware, it still depends on the host's network card. Therefore, if the host needs to disconnect the network, the virtual machine will not be able to get the IP address ~~ All features

Disappear)







Iii. Host-only adapter Mode


Features:

1. the VM cannot access the Internet.

2. Ping between virtual machines

3. the VM can ping the host. (Note that the VM communicates with the host through the NIC named virtualbox host-only network of the host. Therefore, the IP address

Is the IP address 192.168.56.1 of the network adapter, not the IP address you are using to access the Internet)

4. The host can ping the VM.


Application scenarios:

When the host cannot access the Internet (host-only or bridging can be used when the host can access the Internet), a simulated LAN needs to be set up, and all machines can access each other.


Configuration method:

Select host-only adapter for connection mode

Select virtualbox host-Only Ethernet Adapter as the interface Name

Advanced-control chip selection pcnet-fast III

Advanced-reject in Mixed Mode

Advanced-access network cable √

(The Virtual Machine IP address is automatically obtained, or you can configure it yourself. The Gateway is configured as the address of the virtual network card in the host [Default: 192.168.56.1], and the IP address is configured as the same network segment as the virtual network card address)


IP style:

The IP address is in the same network segment as the nic ip address of the local virtualbox host-only network (192.168.56. * by default .*)

Gateway
Nic IP address of virtualbox host-only network (192.168.56.1 by default)


Principle:

The virtualbox host-only network Nic is used for communication. The virtual machine uses the IP address as the gateway. Therefore, the local network of the Local Machine and each virtual machine is simulated,

It should be impossible to access the internet (but some people say that the virtual machine can access the Internet by bridging the virtualbox host-only network adapter, but it is better to directly

It's easy to use bridging. Besides, I didn't try it. Some people also said no, because the host does not provide the routing service, and I am not confused, try it yourself ~~)






Iv. Internal Mode (intranet Mode)


Features:

1. the VM cannot access the Internet.

2. Ping between virtual machines

3. the VM cannot ping the host.

4. The host cannot ping the VM.


Application scenarios:

Isolate virtual machines from each other in an isolated LAN.


Configuration method:

Select internal network for connection mode

Select intnet as the interface Name (you can rename it. All virtual machines placed in the same LAN have the same name)

Advanced-control chip selection pcnet-fast III

Advanced-reject in Mixed Mode

Advanced-access network cable √

(Virtual Machine IP Address: For XP, You can automatically obtain the IP address, but for Linux, you must manually configure the IP address and subnet mask. During manual configuration, you must ensure that the IP addresses of each virtual machine are in the same network segment)


IP style:

IP 169.254.147.9

Subnet Mask 255.255.0.0

No Default Gateway


Principle:

Each virtual machine uses the built-in DHCP server of virtualbox to obtain the IP address. packet transmission does not pass through the network of the host, so the security is high to prevent external packet capture ~






5. Nat mode + port ing


Map a port of the VM to a port of the host so that the host and external machine can access the services provided by the VM ~~

The command is as follows:

(In command line mode, first go to the installation directory of virtualbox; otherwise, the command cannot be found)

Vboxmanage setextradata <VM Name> "vboxinternal/devices/pcnet/0/Lun #0/config/<rule Name>/protocol" TCP

Vboxmanage setextradata <VM Name> "vboxinternal/devices/pcnet/0/Lun #0/config/<rule Name>/guestport" 80

Vboxmanage setextradata <VM Name> "vboxinternal/devices/pcnet/0/Lun #0/config/<rule Name>/hostport" 8000

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.