`
huangro
  • 浏览: 332499 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

访问virtualbox虚拟机中架设的网站

阅读更多
翻译比较累,直接贴上原文:

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).
分享到:
评论

相关推荐

    virtualbox虚拟机网络设置原理解析

    这几天在虚拟机中研究操作系统(OS)的属性问题,众所周知,最经济实惠,最廉价的方法就是架设虚拟机。这段时间我在我的个人电脑上面装了CENTOS、LINUXMINT、WINDOWS8的操作系统,系统是装好了,但是遇到了一个问题...

    虚拟机技术在图书馆的应用——以架设IlasII馆际互借服务器为例.pdf

    虚拟机技术在图书馆的应用,如在IlasII馆际互借服务器的架设中,不仅提高了服务效率,也简化了系统管理,降低了运营成本。随着信息技术的发展,虚拟机将在图书馆的数字化进程中发挥更大的作用,为读者提供更优质的...

    虚拟磁盘 虚拟磁盘组建架设

    1. 创建虚拟磁盘:根据需求选择合适的虚拟机软件(如VMware Workstation、VirtualBox等),在虚拟机配置中添加新的虚拟硬盘,指定类型、大小和路径。 2. 初始化与格式化:创建完成后,需要对虚拟磁盘进行初始化并...

    本机架设虚拟服务器的小软件

    此外,为了安全和性能考虑,用户应该遵循最佳实践,比如定期备份虚拟机、限制不必要的网络访问,并确保操作系统和应用程序都保持最新更新,以防止潜在的安全风险。 总的来说,本机架设虚拟服务器的小软件为用户提供...

    以VirtualBox 架設ubuntu 和joomla 之教學手冊

    通过以上步骤,您可以在VirtualBox中成功安装并配置Ubuntu Server以及Joomla CMS,搭建一个完整的网站开发和测试环境。此外,还可以利用PuTTY进行远程管理和维护,极大地提高了开发效率和灵活性。

    云端伺服器架设-环境设定

    5. **Client/Server架构**:通过简单的但功能强大的COM/XPCOM API,可以对运行中的VirtualBox及其虚拟机进行控制。此外,还有一个命令行工具VboxManage,允许用户通过命令行来管理所有的虚拟机。 6. **前台/后台...

    windows server 2003架设广播式流媒体服务器实验报告

    虚拟机软件如VMware或VirtualBox可以提供这样的环境,使得我们可以在现有的操作系统上模拟一个新的硬件系统,安装并运行Windows Server 2003。确保虚拟机配置足够强大,至少分配2GB内存和一定数量的处理器核心,以便...

    单机一键端

    3. **Bf_Client.vdi**: VDI文件是VirtualBox虚拟机的磁盘映像文件,这里可能是将整个客户端运行环境封装在了一个虚拟机内,确保了系统兼容性和隔离性,使得用户可以在任何支持VirtualBox的平台上运行这个“单机一键...

    ROS 2.9.27架设视频教程

    这个部分可能包括使用如VMware、VirtualBox或Docker等虚拟化工具来创建ROS开发环境,并演示如何在虚拟机中启动ROS节点和服务。 最后,"ROS自做教程.txt"可能包含额外的文字说明和步骤,帮助你在观看视频教程后巩固...

    BigBlueButton安装方法

    #### 二、使用虚拟机架设BigBlueButton服务器 使用虚拟机安装BigBlueButton是最简单快捷的方式。用户可以从官方Wiki页面下载预配置好的虚拟机镜像(http://code.google.com/p/bigbluebutton/wiki/BigBlueButtonVM)...

    云计算OpenStack Cloud Computing Cookbook 英文电子书

    所能支持的虚拟机软件包括:KVM、Xen、VirtualBox 、VMware、QEMU、 LXC 等,几乎涵盖此领域的所有主流软件。无论是架设公有云或私有云,只要涉及虚拟化,Openstack都是首选的软件。OpenStack社区拥有超过130家企业...

    鸟哥的私房菜第四版

    15. **虚拟化技术**:浅析虚拟机(如KVM、VirtualBox)和容器技术(如Docker),以及它们在服务器部署中的应用。 通过学习《鸟哥的私房菜》,读者可以全面了解Linux操作系统,掌握日常管理和运维技能,为成为合格的...

    《计算机网络》实习报告书

    本次实习中,使用 **VirtualBox** 作为虚拟化平台,在 Ubuntu Server 上构建虚拟服务器。这一过程包括创建虚拟机、安装操作系统以及配置网络连接等步骤。虚拟服务器的设置对于后续的协议分析至关重要,因为它提供了...

Global site tag (gtag.js) - Google Analytics