VirtualBox Virtual Machine Network settings (four ways)

Source: Internet
Author: User
Tags get ip domain name server custom name ssh server

The VirtualBox provides four network access modes, namely:
1. NAT Network Address Translation mode (Nat,network addressing translation)
2, bridged Adapter bridge mode
3. Internal Internal network mode
4. Host-only Adapter Host Mode

The first NAT mode
Explain:
Nat mode is the simplest way to implement virtual machine access, you can understand: Vhost access to the network all the data is provided by the host, Vhost is not real in the network, the host and any machine in the network can not view and access to the existence of vhost.
Virtual machine vs. host relationship:
Only one-way access, the virtual machine can be accessed over the network to the host, the host cannot access the virtual machine over the network.
The relationship between the virtual machine and other hosts in the network:
Only one-way access, the virtual machine can access other hosts on the network, and other hosts cannot access the virtual machine over the network.
The relationship between a virtual machine and a virtual machine:
The virtual machines and virtual machines are completely independent from each other 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 for a virtual machine can be set to use NAT, the first NIC is connected to the private network 10.0.2.0, the second network adapter is connected to the private networking 10.0.3.0, and so on. The default resulting client IP address is 10.0.2.15, the gateway is 10.0.2.2, and the domain name server (DNS) is 10.0.2.3, which can be manually referenced for modification.
Advantages and disadvantages of NAT scenarios:
When a laptop is plugged into a network cable: the virtual machine can access the host, the virtual machine can access the Internet, and after the port mapping is done (and finally explained), the host can access the services on the virtual machine (such as the database).
When the notebook is not plugged into a network cable: The host's "local Connection" has a red fork, the virtual machine can access the host, the virtual machine can not access the Internet, after the port mapping, the host can access the services on the virtual machine (such as the database).

The second type of bridged adapter mode
Explain:
The bridge mode is one of my favorite patterns, and the simulation is quite perfect. You can understand that it is through the host network card, erected a bridge, directly connected to the network. As a result, it allows the virtual machine to be assigned to a network of independent IPs, all of which function exactly like real machines in the network.
Virtual machine vs. host relationship:
can access each other because the virtual machine has a separate IP in the real network segment, the host is in the same network segment as the virtual machine, and can be accessed from each other through the respective IP.
Virtual machines in other host relationships on the network:
can access each other, as the virtual machine has a separate IP in the real network segment, and the virtual machine is in the same network segment as all the other hosts in the network, each of which can access each other through the respective IP.
Virtual machines in virtual machine relationships:
Can visit each other for the same reason.
IP: DHCP is typically assigned to the same network segment as the host's "Local Connection" IP. The virtual machine can communicate with the host computer.
When the laptop is plugged in: (If there is a DHCP server in the network) the host and the virtual machine are given an IP via DHCP, and the two IPs are in the same network segment. The host and virtual machine can ping through, the virtual machine can be on the Internet.
When the laptop is unplugged: The host cannot communicate with the virtual machine. The host's "local Connection" has a red fork, and it cannot specify the IP manually. The virtual machine also cannot get IP address through DHCP, and after manually specifying the IP, it cannot communicate with the host because the host has no IP.
At this time the host's VirtualBox host-only network network card is IP, 192.168.56.1. A virtual machine can also ping a host, even if it manually specifies an IP 192.168.56.*.

The third model of internal
Explain:
Intranet mode, as the name implies is the internal network mode, virtual machine and the external network completely disconnected, only the virtual machine in the virtual machine between the internal network mode.
Virtual machine vs. host relationship:
Cannot access each other, are not part of the same network, and cannot access each other.
Virtual machines and other host relationships in the network:
Cannot visit each other for the same reason.
Virtual machine vs. virtual machine relationships:
can access each other, provided that the two virtual machines set the same network name when the network is set up. As in the configuration diagram above, the name is intnet.
The Ip:virtualbox DHCP server assigns the IP to it, typically 192.168.56.101, because it is from 101 and can be manually specified 192.168.56.*.
When a laptop is plugged into a network cable: the virtual machine can communicate with the host's VirtualBox host-only network network card
This scheme is not affected by the presence of a red fork in the host local connection (NIC).

Fourth type Host-only Adapter mode
Explain:
Host mode, this is a more complex mode, need to have a relatively solid network of basic knowledge to play around. Can be described in the previous several modes of implementation of the function, in this mode, through the virtual machine and network card settings can be implemented.
We can understand that vbox in the host to simulate a dedicated virtual machine to use the network card, all virtual machines are connected to the network card, we can set up this network card to achieve the Internet and many other functions, such as (network card sharing, network card bridging, etc.).
Virtual machine vs. host relationship
The default cannot access each other, the two sides do not belong to the same IP segment, the HOST-ONLY network card default IP field is 192.168.56.X subnet mask is 255.255.255.0, the subsequent virtual machines are assigned to this network segment. Through network card sharing, network card bridging, etc., virtual machines can be accessed by the host.
Relationship between virtual machine and network host
The default is not accessible to each other, for the same reason, by setting, you can achieve mutual access.
Virtual machine and virtual machine relationships
The default is to access each other, all in one network segment.
Virtual Machine Access host is the host of the VirtualBox host-only Network network card ip:192.168.56.1, regardless of the host "local connection" there is no red fork, always pass.
Host access to the virtual machine, with the virtual machine's network card 3 ip:192.168.56.101, regardless of the host "local connection" there is no red fork, always pass.
Virtual machine access to the Internet, with its own network card 2, then the host to be able to through the "local connection" wired Internet, (Wireless card not)

Through the understanding of the above-mentioned network models, we can use it flexibly, simulating the formation of any kind of network environment we want.
For example, I would like to simulate a host, monitoring a LAN network environment of Internet conditions.
First I opened two virtual machines vhost1 and Vhost2, of course, if the hardware allows, I can also add vhost3, Vhost4 ...
All the vhost I have set to Internat intranet mode, the network name is intnal, the gateway is 192.168.56.100, which means to surf the internet via the 192.168.56.100 network card. One of the vhost1 I set as a dual network card, one for the intranet mode (192.168.56.100), one for the bridge mode (192.168.1.101). Two network cards set up dual network card sharing internet
The virtual machine is a local area network, in which there is a virtual machine vhost1 through the connection with the outside network, all the virtual machines in the local area network through the Vhost1 to implement the Sisu network. This allows the VHOST1 to monitor the entire VM LAN connection.

NAT Setting Port Mappings
http://huzhangsheng.blog.163.com/blog/static/34787784200802801435931/
You can set up a service for a virtual machine (such as a WEB service) by using the command-line tool Vboxmanage Proxy. You need to know which port the service of the virtual machine is using, and then decide which port to use on the host (usually but not always want to use the same port for the virtual machine and host). Providing a service on the host requires a port that you can use on any port that is not ready to be serviced on the host. How to set up a new NAT example, connecting to an 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
Description: Vboxmanage is a command-line program, please check your VirtualBox installation directory, ' Linux Guest ' is the virtual hostname. Guestssh is a custom name, you can set any of the above three commands, the virtual machine's 22 port forwarding to the host's 2222 port.
For another example, I installed the APACHE2 server on the virtual machine Debian, using port 80, which is mapped to the 80 port 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, turn off VirtualBox and run the virtual machine, I install VirtualBox on WinXP, install Debian 4.02r in the virtual machine, the virtual machine name is Debian, and install apache2 php5 mysql-serv Er, on the host with IE Browse http://localhost, successfully forwarded to the virtual machine Debian apache2 Web server

Above Source: http://www.cnblogs.com/coltiam/archive/2010/03/26/1696939.html

Personal feeling through the use of port mapping is very uncomfortable, not as fast as the bridge directly, now most of the time to connect to the network is no problem, port mapping also needs to be in the host and the virtual machine to open an additional service, feel uncomfortable.

The Network Configuration page has 4 scenarios:

1:nat Network address translation (translation)

2:birdged Network Bridging

3:internal Network Intranet (can be between virtual machines and virtual machines)

4:host-only only communicates with the host (presumably)

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 the work network environment, are distributed through DHCP, sometimes there is no network, "local connection" has a red fork (on the host and virtual machine communication has an impact).

"VirtualBox host-only Network network card" ip:192.168.56.1, because the VirtualBox DHCP server IP is 192.168.56.100, to be on the same network segment.

Virtual machine: To be able to communicate with the host, to be able to access the Internet (no need to be Internet access).

System: Win2003

Network card 1, network card 2, network card 3 said the configuration of each network card

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

---------------------------the configuration of each network card--------------------------------------------

Nic 1: Using NAT scheme

ip:10.0.2.15

Gateway: 10.0.2.2

dns:10.0.2.3


Why is this configured? Because VirtualBox's help, the following paragraph is explained (English to Chinese):

Multiple network cards for a virtual machine can be set to use NAT, the first NIC is connected to the private network 10.0.2.0, the second network adapter is connected to the private networking 10.0.3.0, and so on. The default resulting client IP address is 10.0.2.15, the gateway is 10.0.2.2, and the domain name server (DNS) is 10.0.2.3, which can be manually referenced for modification.


Advantages and disadvantages of NAT scenarios:

When a laptop is plugged into a network cable: the virtual machine can access the host, the virtual machine can access the Internet, and after the port mapping is done (and finally explained), the host can access the services on the virtual machine (such as the database).

When the notebook is not plugged into a network cable: The host's "local Connection" has a red fork, the virtual machine can access the host, the virtual machine can not access the Internet, after the port mapping, the host can access the services on the virtual machine (such as the database).


Nic 2: Using the Birdged Network solution

IP: DHCP is typically assigned to the same network segment as the host's "Local Connection" IP. The virtual machine can communicate with the host computer.

When the laptop is plugged in: (If there is a DHCP server in the network) the host and the virtual machine are given an IP via DHCP, and the two IPs are in the same network segment. The host and virtual machine can ping through, the virtual machine can be on the Internet.

When the laptop is unplugged: The host cannot communicate with the virtual machine. The host's "local Connection" has a red fork, and it cannot specify the IP manually. The virtual machine also cannot get IP address through DHCP, and after manually specifying the IP, it cannot communicate with the host because the host has no IP.

At this time the host's VirtualBox host-only network network card is IP, 192.168.56.1. A virtual machine can also ping a host, even if it manually specifies an IP 192.168.56.*.

Nic 3: Using the HOST-ONLY scheme

The Ip:virtualbox DHCP server assigns the IP to it, typically 192.168.56.101, because it is from 101 and can be manually specified 192.168.56.*.

When a laptop is plugged into a network cable: the virtual machine can communicate with the host's VirtualBox host-only network network card

When a laptop is unplugged: the virtual machine can communicate with the host's VirtualBox host-only network network card

This scheme is not affected by the presence of a red fork in the host local connection (NIC).


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

Above three options, you can right click on the bottom of the virtual machine window two small TV icons quickly switch. Meet a variety of network environments.

I didn't try it on the internal Network plan.


Summary of the above three scenarios


The following two scenarios are enabled for in-step:

Nic 2: Using the Birdged Network solution

Nic 3: Using the HOST-ONLY scheme

Virtual Machine Access host is the host of the VirtualBox host-only Network network card ip:192.168.56.1, regardless of the host "local connection" there is no red fork, always pass.

Host access to the virtual machine, with the virtual machine's network card 3 ip:192.168.56.101, regardless of the host "local connection" there is no red fork, always pass.

Virtual machine access to the Internet, with its own network card 2, then the host to be able to through the "local connection" wired Internet, (Wireless card not)

Transferred from: https://www.douban.com/group/topic/15558388/

VirtualBox Virtual Machine Network settings (four ways)

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.