Detailed VirtualBox virtual machine network environment analysis and build-nat, Bridge, Host-only, Internal, port mapping __ development tools

Source: Internet
Author: User
Tags get ip

Original link: http://www.jb51.net/article/98575.htm

--------------------------------------------------

This paper takes VirtualBox as an example

If a host cannot ping the virtual machine, first make sure that the virtual machine firewall is turned off.

First, Nat mode

Characteristics:

1. If the host can surf the Internet, the virtual machine can surf the internet

2, the virtual machine can not ping through

3, the virtual machine can ping the host (at this time, ping virtual machine gateway, that is ping host)

4, the host can not ping the virtual machine

Application Scenario:

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

Configuration method:

Connection mode Select Network Address translation (NAT)

Advanced-Control chip selection Pcnet-fast III

Advanced-Promiscuous mode rejection

Advanced-access Network cable √

(Virtual machine IP automatic acquisition)

IP Style:

IP 10.0.2.15

Gateway 10.0.2.2

Note that the gateways here may be the same value in different virtual machines, but this belongs to a different Nat Engine, so that virtually every virtual machine is not using the same gateway

principle:

The request of the virtual machine is passed to the NAT Engine, which uses the host for external network access, and the returned packet is Engine by NAT to the virtual machine.

second, bridged adapter mode (bridging mode)

Characteristics:

1. If the host can surf the Internet, the virtual machine can surf the internet

2, the virtual machine can ping through

3, the virtual machine can ping through the host

4, the host can ping the virtual machine

The above points are based on the premise that the host can surf the internet

5, if the host can not access the Internet, all 1-4 features are not

Application Scenario:

Virtual machines require access to the Internet, and virtual machines completely simulate a solid machine

Configuration method:

Connection mode select Bridging network card

Interface Name selection (if your notebook has a wireless card and a wired network card, you need to choose according to the current way of the Internet)

Advanced-Control chip selection Pcnet-fast III

Advanced-Promiscuous mode rejection

Advanced-access Network cable √

(Virtual machine IP automatic acquisition)

IP Style:

IP and native IP in the same network segment

The gateway is the same as the native gateway

principle:

Through the host network card, erecting a bridge, directly connected to the network. It allows the virtual function to be assigned to a network of independent IP, all network functions completely and

The same as the real machine in the network.

(The virtual machine gets the IP address from the DHCP service on the host's network, so logically, the two are completely independent, but the fact is that the virtual machine is not

Have independent hardware, it is still to rely on the host network card, therefore, the host to disconnect the network, virtual machines will not be able to get IP, so hehe ~ ~ All characteristics of the whole

Disappeared)

three, host-only adapter mode

Features:

1, the virtual machine can not access the Internet

2, the virtual machine can ping through

3, the virtual machine can ping the host (note that the virtual machine and host communication is through the host named VirtualBox host-only Network network card, so IP is the network card IP 192.168.56.1, rather than you are now using the Internet IP)

4, the host can ping the virtual machine

Application Scenario:

When the host is unable to access the Internet (the host can access the Internet can use Host-only, can also use bridge), need to build an analog LAN, all machines can exchange visits

Configuration method:

Connect mode Select Host only (HOST-ONLY) adapter

Interface Name Selection VirtualBox host-only Ethernet Adapter

Advanced-Control chip selection Pcnet-fast III

Advanced-Promiscuous mode rejection

Advanced-access Network cable √
(Virtual machine IP automatic acquisition, can also be configured, the gateway configured as the main machine in the Virtual network card address "default for 192.168.56.1", IP configuration and virtual network card address with the same network segment address)

IP Style:

IP and native VirtualBox host-only network network card IP is within the same network segment (default 192.168.56.*)

Network Guan Ben VirtualBox host-only Network network card IP (default 192.168.56.1)

principle:

Through the VirtualBox host-only Network network card communication, the virtual machine with this IP as a gateway, thus simulating a local and individual virtual machine LAN, as the name implies,

should be unable to access the Internet (but it is said that the VirtualBox host-only Network network card can be bridged and other operations to make the virtual machine can access the Internet, but this is not as direct

The use of bridges to the easy, and, oh, I did not try to succeed, some people also said not, because the host does not provide routing services, I am also not good at the end of the chaos, you try it ~ ~)

Four, internal mode (intranet mode)

Features:

1, the virtual machine can not access the Internet

2, the virtual machine can ping through

3, the virtual machine can not ping through the host

4, the host can not ping the virtual machine

Application Scenario:

Allow each virtual machine to be in an isolated LAN, allowing them to communicate with each other, isolated from the outside world (including the host)

Configuration method:

Connect Mode Select Internal Network

Interface Name Select Intnet (can be renamed, all the virtual machines placed on the same local area network this name is the same)

Advanced-Control chip selection Pcnet-fast III

Advanced-Promiscuous mode rejection

Advanced-access Network cable √
(Virtual machine IP: For xp automatically get IP, but for Linux, you must manually configure the IP and subnet mask, manual configuration to ensure that each virtual machine IP in the same network segment)

IP Style:

IP 169.254.147.9

Subnet Mask 255.255.0.0

Default Gateway None

principle:

Each virtual machine uses VirtualBox built-in DHCP server to get IP, packet transmission does not go through the host network, so the security is high, to prevent external grab bag ~

Five, Nat mode + port mapping

Mapping a virtual machine port to a host port allows the host and external machines to access the services provided by the virtual machine Oh ~ ~

The order is as follows:

(in command line mode, first to the VirtualBox installation directory, 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

The above is the entire content of this article


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.