翻译比较累,直接贴上原文:
6.3.1. Configuring port forwarding with NAT
As the virtual machine is connected to a private network internal to VirtualBox and invisible to the host, network services on the guest are not accessible to the host machine or to other computers on the same network. However, VirtualBox can make selected services available outside of the guest by using port forwarding. This means that VirtualBox listens to certain ports on the host and resends all packets which arrive on them to the guest on the ports used by the services being forwarded.
To an application on the host or other physical (or virtual) machines on the network, it looks as though the service being proxied is actually running on the host (note that this also means that you cannot run the same service on the same ports on the host). However, you still gain the advantages of running the service in a virtual machine -- for example, services on the host machine or on other virtual machines cannot be compromised or crashed by a vulnerability or a bug in the service, and the service can run in a different operating system than the host system.
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 use 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 an ssh server on the guest 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
The above example assumes a PCNet virtual network card; if you have configured the guest to use the Intel PRO/1000, replace "pcnet" with "e1000" in the above commands. Similarly, if you want to configure a different interface instance replace the /0/ with the appropriate index. pcnet and e1000 are counted separately in this respect, and counting starts at 0 for both types.
The name guestssh is an arbitrary one chosen for this particular forwarding configuration. With that configuration in place, all TCP connections to port 2222 on the host will be forwarded to port 22 on the guest. Protocol can be either of TCP or UDP (these are case insensitive). To remove a mapping again, use the same commands, but leaving out the values (in this case TCP, 22 and 2222).
It is not possible to configure incoming NAT connections while the VM is running. However you can change the settings for a VM which is currently saved (or powered off at a snapshot).
分享到:
相关推荐
VMVirtualBox虚拟机访问本地磁盘的方法
通过本文档的描述,对VirtualBox虚拟机进行相关设置,可以是虚拟机ping通外网,这样虚拟机可以很方便的进行在线安装各种软件。
给VirtualBox虚拟机(装载了Ubuntu16.04系统)配置了两张网卡,网络模式分别为“网络地址转换(NAT)”和“仅主机(Host-Only)适配器”,其中,enp0s3网卡(NAT)用于外网访问,而enp0s8网卡(Host-Only)用于主机...
VirtualBox虚拟机实现桥接方式;图文显示。
Virtualbox虚拟机安装Ubuntu图文教程
在VirtualBox的虚拟机上默认虚拟机的时间是会和物理机同步的,但可以通过下面的命令来关闭
Oracle VM VirtualBox 虚拟机消失,系统消失,电脑重启之后,之前创建的虚拟机XP、Linux……莫名其妙的突然找不到了,消失了。这里有解决办法。图文并茂。
Linux主机和VirtualBox虚拟机局域网互通.docx
VirtualBox虚拟机XP与宿主机Ubuntu互访共享文件夹.pdf
VirtualBox虚拟机使用教程VirtualBox虚拟机使用教程VirtualBox虚拟机使用教程
Vagrant+virtualbox虚拟机教程.zip 虚拟机你只会使用vmware吗? 来看看Oracle的虚拟机VirtualBox 以及用Vagrant来搭建服务器
irtualBox虚拟机详细使用教程
VirtualBox虚拟机 Portable 中文绿色便携版 32位_XP85.zip
VirtualBox虚拟机网络设置,VirtualBox的提供了四种网络接入模式,它们分别是: 1、NAT 网络地址转换模式(NAT,Network Address Translation) 2、Bridged Adapter 桥接模式 3、Internal 内部网络模式 4、Host-only ...
在VirtualBox虚拟机下安装DOS622
该镜像文件可以安装到VMware Workstation 或virtualbox虚拟机中。
VirtualBox虚拟机安装包,VirtualBox虚拟机安装包,VirtualBox虚拟机安装包,VirtualBox虚拟机安装包
Oracle VM VirtualBox虚拟机安装Mac OS X详细图解
本文档主要内容为,在Windows下怎么样安装虚拟机VirtualBox-4.2.6,并在虚拟机上安装Linux系统Ubuntu 10.04,以及相应环境的搭建。
如何在VirtualBox虚拟机中建立的服务器上使用动态域名解析知识.pdf