使用VirtualBox进行端口转发

我有一个运行Ubuntu的virtualbox虚拟机

Ubuntu客户端正在运行一个监听端口3000的Web服务器( http://127.0.0.1:3000 )

主机是Windows Vista。

我已经使用VBoxManageconfiguration端口转发

如果我查询使用VboxManage getextradata“MyMachine”的configuration,我得到

GUI / AutoresizeGuest,值:on键:GUI / Fullscreen,值:off键:GUI / LastCloseAction,值:shutdown键:GUI / LastWindowPostion,值:9,34,640,529,最大键:GUI / MiniToolBarAlignment,值:bottom键:GUI / MiniToolBarAutoHide,值:off键:GUI / SaveMountedAtRuntime,值:yes键:GUI / Seamless,值:off键:GUI / ShowMiniToolBar,值:yes键:VBoxInternal / Devices / pcnet / 0 / LUN#0 / Config / guesthttp / GuestPort,值:3000 Key:VBoxInternal / Devices / pcnet / 0 / LUN#0 / Config / guesthttp / HostPort,值:3000 Key:VBoxInternal / Devices / pcnet / 0 / LUN#0 / Config / guesthttp / Protocol ,价值:TCP

这看起来应该工作…

但是,当我尝试从主机(Windows框)访问Web服务器时,我没有得到回应。

我运行了一个netstat的窗口框,没有什么似乎是监听端口3000这解释了为什么forwrding不工作。

请注意,我已经在防火墙closures的情况下进行了testing

我使用的VirtualBox版本是3.1.4

有任何想法吗?

我假设这个问题与你之前关于VirtualBox的问题有关。

让您的Ubuntu Web服务器configuration为侦听IP地址为10.0.2.15的以太网networking接口(可能是eth0)? 如果没有,请configuration您的Web服务器以侦听以太网networking接口。 我的猜测是,您的Web服务器只能configuration为监听环回接口127.0.0.1 – 127.0.0.1只能在您的Ubuntu VM中访问。 即它不能从Windows主机访问。

正如您在上一个问题中提到的那样:将VirtualBoxconfiguration为使用桥接networking模式,以便您的虚拟机成为您networking上的另一台计算机。 桥接networking模式变得越来越简单,您不必费心使用VirtualBox端口转发。 🙂