从Windows浏览器访问Ubuntu虚拟机主机



我有一个运行Hellow World Blask应用程序的VirtualBox Ubuntu机器。

我尝试在127.0.0.1:5000和0.0.0.0.0:5000

上显示应用程序显示

但是,当我尝试在Windows浏览器上加载时,这两者都无法解决。

当我在ubuntu虚拟机中运行ifconfig时,我会得到这个:

ifconfig -a
eth0      Link encap:Ethernet  HWaddr 08:00:27:6f:2c:93  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe6f:2c93/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:657 errors:0 dropped:0 overruns:0 frame:0
          TX packets:559 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:61322 (61.3 KB)  TX bytes:73104 (73.1 KB)
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

,当我的Windows机器上运行IP配置时,我会得到此:

ipconfig
Windows IP Configuration

Ethernet adapter Local Area Connection:
   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
Wireless LAN adapter Local Area Connection* 4:
   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
Ethernet adapter Bluetooth Network Connection:
   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
Wireless LAN adapter Local Area Connection* 2:
   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
Wireless LAN adapter Wi-Fi:
   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::2140:c809:4677:98bc%3
   IPv4 Address. . . . . . . . . . . : 10.32.16.32
   Subnet Mask . . . . . . . . . . . : 255.0.0.0
   Default Gateway . . . . . . . . . : 10.128.128.128
Ethernet adapter VirtualBox Host-Only Network:
   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::3568:3fc7:1697:a475%10
   IPv4 Address. . . . . . . . . . . : 192.168.56.1
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :
Tunnel adapter isatap.{2543650F-5CEA-40B8-B085-A54A628D3DCE}:
   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
Tunnel adapter isatap.{8A555006-09A6-4A20-986D-F59F5741DCCE}:
   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

但是由于某种原因,当我进入192.168.56.1时,在Windows Browswer中,它加载了一个白页。如果我去192.168.56.1:5000说它无法连接。

在我的虚拟盒中,我将其"附加到:nat"和端口转发规则显示

SSH TCP 127.0.0.1主机端口2222访客IP空为空,访客端口为22

我的烧瓶应用显示

 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
 * Restarting with stat

也尝试了

 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 * Restarting with stat

回答您可以在VirtualBox文档中找到的问题:https://www.virtualbox.org/manual/ch06.html 6.3.1。配置端口转发使用NAT

您可以将端口5000从访客OS(Ubuntu)转发为托管。在主机方面,您可以使用相同的端口号(如果没有其他人占用)

最新更新