问题描述
这是我的设置:
- Host: Windows XP
- Guest: Ubuntu 10.04
- Networking: NAT
我正在Guest上设置一个Apache Web服务器,但是我希望能够在Windows机器上执行此操作:
I am setting an Apache web server on the Guest, but I want to be able to do this on the Windows machine:
- go to the browser, type http://localhost:8000
此外,我尝试将网络更改为桥接,并获得了一个新IP.但是当我尝试执行http://:8000时,它说它无法连接.
Also, I tried to change my networking to bridge and I got a new IP. But when I tried to do http://:8000, it says that it could not connect.
推荐答案
网络通信主机->访客
连接到来宾并找到IP地址:
Network communication Host -> Guest
Connect to the Guest and find out the ip address:
ifconfig
结果示例(IP地址为10.0.2.15):
example of result (ip address is 10.0.2.15):
eth0 Link encap:Ethernet HWaddr 08:00:27:AE:36:99
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
转到Vbox实例窗口->菜单->网络适配器:
Go to Vbox instance window -> Menu -> Network adapters:
- 适配器应为NAT
- 点击端口转发"
- 插入新记录(+图标)
- 对于主机ip,请输入127.0.0.1,对于从先前获得的来宾ip地址,请输入.步骤(在我的情况下为10.0.2.15)
- 如果您的端口是8000,请在两个端口上都放,但是您可以根据需要更改主机端口
- adapter should be NAT
- click on "port forwarding"
- insert new record (+ icon)
- for host ip enter 127.0.0.1, and for guest ip address you got from prev. step (in my case it is 10.0.2.15)
- in your case port is 8000 - put it on both, but you can change host port if you prefer
转到主机系统,然后在浏览器中尝试:
Go to host system and try it in browser:
http://127.0.0.1:8000
或您的网络IP地址(通过运行ipconfig在主机上查找).
or your network ip address (find out on the host machine by running: ipconfig).
在这种情况下,不需要端口转发,通信将通过LAN返回到主机.
In this case port forwarding is not needed, the communication goes over the LAN back to the host.
在主机上-找到您的IP地址:
On the host machine - find out your netw ip address:
ipconfig
结果示例:
IP Address. . . . . . . . . . . . : 192.168.5.1
在来宾计算机上,您可以直接与主机通信,例如用ping检查它:
On the guest machine you can communicate directly with the host, e.g. check it with ping:
# ping 192.168.5.1 PING 192.168.5.1 (192.168.5.1) 56(84) bytes of data. 64 bytes from 192.168.5.1: icmp_seq=1 ttl=128 time=2.30 ms ...
这篇关于Virtualbox的“向前端口"是指虚拟机.从来宾到主持人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!