Virtualbox Nat settings and port forwarding

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

Http://huzhangsheng.blog.163.com/blog/static/34787784200802801435931/

Computer notes

Read 3898 comments 3
Font Size:
Large
Large
 
Medium
Medium
 
Small
Small

 

Lin Chuan Zhong Hu Changsheng

This is my translation of the NAT settings provided by virtualbox. I am not an English major. Not complete, to be continued. Reprinted my article. Please indicate the source. Thank you very much.

1. Network Address Translation (NAT)

Network Address Translation (NAT) is
Simplest way of accessing an external network from a virtual machine.
Usually, it does not require any con resume guration on the host network and
Guest system. For this reason, it is the default networking mode in
Virtualbox.

Network Address Translation (NAT) is the easiest way to access the external network from a virtual machine. Generally, it does not require any configuration on the host network or client. For this reason, it is the default network mode.

A Virtual Machine with NAT enabled acts
Much like a real computer that connects to the Internet through
Router. The "Router", in this case, is the virtualbox networking
Engine, which maps Traf implements C from and to the Virtual Machine
Transparently. The disadvantage of NAT mode is that, much like
Private network behind a router, the virtual machine is invisible and
Unreachable from the outside Internet; you cannot run a server this way
Unless you set up port forwarding (described below ).

Set to use NAT
A virtual machine connected in this way can access the Internet like a real computer, and the host is a router. In this way, use virtualbox
The network engine transparently maps virtual machines to external networks. Nat is inconvenient. It is like a private network behind a vro. From the perspective of the Internet, virtual machines are invisible and inaccessible;
You cannot run a server on a virtual machine because the external network cannot access the internal machine connected through NAT, unless you have set port forwarding (below ).

The virtual machine has es its network
Address and con login guration on the private network from a DHCP server that
Is integrated into virtualbox. The address which the Virtual Machine
Specified ES is usually on a completely different network to the host.
More than one card of a virtual machine can be set up to use NAT,
Specified rst card is connected to the private network 10.0.2.0, the second card
To the network 10.0.3.0 and so on.

The Virtual Machine obtains a Private URL from a virtualbox integrated DHCP server.
This website is a completely different network for the host. Multiple NICs of a virtual machine can be configured with Nat. The first Nic is connected to the private network.
10.0.2.0, the second Nic is connected to the private network 10.0.3.0, and so on. Default Client IP (IP
Address) is 10.0.2.15, Gateway is 10.0.2.2, and Domain Name Server (DNS) is 10.0.2.3. You can refer to this manual for repair.
Change.

The Network frames sent out by the guest
Operating system are supported ed by virtualbox's Nat engine, which
Extracts the TCP/IP data, and resends it using the host operating
System. To an application on the host, or to another computer on
Same network as the host, it looks like the data was sent by
Virtualbox application on the host, using an IP address belonging
The host. virtualbox listens for replies to the packages sent, and
Repacks and resends them to the guest machine on its private network.

The Network frames sent from the client (Virtual Machine) are received and extracted by the virtualbox Nat engine.
TCP/IP data, and then install virtualbox
. An application sent to a host, or to another computer on the same network of the host, it looks like a program installed on the host.
Virtualbox sends data through an IP address of the host. Virtualbox
Listen to the response of the data package, repackage it through the client's private network, and send it to the client.

You can set up a guest service which you
Wish to proxy using the command line tool vboxmanage. You will need
Know which ports on the guest the service uses and to decide which
Ports to use on the host (often but not always you will want to se
Same ports on the guest and on the host). You can use any ports on
Host which are not already in use by a service. An example of how
Set up incoming Nat connections to a SSH server on the guest requires
The following three commands:

You can set a virtual machine service (such as a web service) by using the command line tool
Vboxmanage
Proxy. You need to know which port is used by the virtual machine service, and then decide which port is used on the host (usually but not always want to make the virtual machine and the host use the same port ). Provide a service requirement on the host
Using a port, you can use any port on the host that is not prepared for service provision. How to set up a new Nat instance and connect to an SSH
Server, the following three commands are required:

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 query your virtualbox
Installation directory. "Linux guest" is the virtual host name. Guestssh is a custom name. You can set it as needed.
The port is forwarded to port 2222 of the host.

For example, I installed the apache2 server on the Virtual Machine Debian and used port 80 to map it 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: To make the settings take effect, turn off virtualbox and run the VM.
Virtualbox is installed on WINXP and Debian 4.02r is installed on the virtual machine. The virtual machine name is Debian and apache2 is installed.
PhP5 mysql-server, browsed http: // localhost on the host using IE, and successfully forwarded to apache2 of Debian Virtual Machine
On the web server, I found that virtualbox settings may be more flexible and powerful than VMware.

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.