问题描述
我正在尝试使用VirtualBox进行简单的端口转发,并且看来VirtualBox.exe在主机上侦听该端口,但实际上并未将连接转发给来宾.我尝试了多个端口,并多次重启了VirtualBox.另一方面,来宾与主机之间的连接很好.这是信息:
I'm trying simple port forwarding with VirtualBox and it appears VirtualBox.exe is listening on the host to the port, but not actually forwarding the connection to the guest. I've tried on multiple ports, and I've restarted VirtualBox several times. Guest to host connectivity, on the other hand, is fine. Here's the info:
Host: Win7 x64
Guest: Win7 x64
VirtualBox version: VirtualBox 4.2.10
Firewalls: All firewalls on host and guest disabled.
Virtual Box > Machine Settings > Network
Adapter 1:
Attached to: NAT
Cable Connected : True
Port Forwarding:
Rule 1: TCP, HostIP=127.0.0.1, HostPort=8081, GuestIP=127.0.0.1, GuestPort=8081
On Host:
[VirtualBox.exe] TCP 127.0.0.1:8081 IBM-6KT5OPCF76P:0 LISTENING
On Guest:
I never get the connection request on port 8081 or any others I've tried.
有什么想法吗?由于多种原因,我想避免使用VirtualBox的桥接适配器.我的印象是,使用VirtualBox进行NAT端口转发相对简单.
Any ideas? I'd like to avoid using VirtualBox's bridged adapter for multiple reasons. I was under the impression that NAT port forwarding was relatively straightforward with VirtualBox.
谢谢!
推荐答案
您以错误的方式指出了来宾ip,它应该是来宾的ip(如果您为来宾静态分配了ip地址)或将其留空.请注意,您将主机ip指向127.0.0.1,这意味着您只能从端口访问要转发的端口(如果不是您想要的端口,则也应该为空).
You've pointed guest ip in wrong manner it should be ip of guest (if you're statically assign ip address to guest) or leave it empty. Note you're pointed host ip as 127.0.0.1 it means that port you're forwarding will be accessible only from port (if it isn't what you're desired it should be empty as well).
VBoxManage modifyvm "win" --natpf1 ",tcp,,8081,,8081"
也许这是您想要做的. (请在此处查看更多详细信息)
perhaps this is something you've wanted to do. (please look here for more details)
这篇关于VirtualBox端口转发不适用于NAT适配器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!