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 the simplest way of accessing an external network from a virtual machine. usually, it does not require any con except 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, www.2cto.com is the default network mode.
A virtual machine with NAT enabled acts much like a real computer that connects to the Internet through a 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 a 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 ).
A virtual machine connected through NAT can access the Internet like a real computer, and the host is a router. In this way, the virtual machine is transparently mapped to the external network through the VirtualBox network engine. NAT is inconvenient. It is like a private network after 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 has ES is usually on a completely different network to the host. as more than one card of a virtual machine can be set up to use NAT, the 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, and the second Nic is connected to the private network 10.0.3.0. The Default Client ip Address is 10.0.2.15, the Gateway is 10.0.2.2, And the DNS is 10.0.2.3.
The network frames sent out by the guest operating system are stored 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 the same network as the host, it looks like the data was sent by the VirtualBox application on the host, using an IP address belonging to 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 frame sent from the client (Virtual Machine) is received by the NAT engine of VirtualBox. The TCP/IP data is extracted and re-sent through the operating system of the host (that is, the operating system of VirtualBox is installed. An application sent to a host, or to another computer on the same network of the host, it looks like a program VirtualBox installed on the host, through a host's IP address, send data. VirtualBox listens to the response of the data package and repacks and sends it to the client through the client's private network.
You can set up a guest service which you wish to proxy using the command line tool VBoxManage. you will need to 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 the same ports on the guest and on the host ). you can use any ports on the host which are not already in use by a service. an example of how to 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 ). A port is required to provide a service on the host. You can use any port on the host that is not prepared to provide the service. How to set up a new NAT instance and connect to an ssh server on a VM 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. Check your VirtualBox installation directory. "Linux Guest" is the virtual host name. Guestssh is a custom name. You can set it as needed. Use the preceding three commands to forward port 22 of the VM 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 virtual machine. I have installed VirtualBox on winxp and debian 4.02r on the virtual machine. The virtual machine name is debian, apache2 php5 mysql-server is installed, and http: // localhost is browsed with IE on the host, which is successfully forwarded to The apache2 web server of the Virtual Machine debian: virtualBox may be more flexible and powerful than vmware.