【问题标题】:Addressing localhost from ubuntu to windows 8 via Virtualbox通过 Virtualbox 将本地主机从 ubuntu 寻址到 Windows 8
【发布时间】:2019-04-15 14:26:07
【问题描述】:

我正在 Windows 8 中使用 springboot 开发一个简单的 Web 应用程序。

当我在 Ubuntu 中将 jar 文件部署到 docker 并运行容器时,我可以看到它在地址 10.0.2.15:8082 上正常工作,这是一个本地 IP 地址。

我想要在我的 Windows 8 中连接此 IP 地址,然后我将使用邮递员发布一些 JSON 变量等。但我无法从 Windows 8 连接 10.0.2.15:8082

我的 VirtualBox 适配器连接到 NAT 并给出了一些规则:

我还尝试更改主机和访客规则,但也没有用。

当我在 Windows 8 中运行该应用程序并使用 192.168.56.1:8082 进行检查时,它会成功,并且我可以在具有相同地址的 Ubuntu 中看到相同的结果。但不能让它工作。

我希望在我的 Windows 8 中连接 ubuntu 的 localhost。

【问题讨论】:

    标签: docker ubuntu localhost virtual-machine virtualbox


    【解决方案1】:

    我找到了答案;

    关闭 vm 后,我添加了第二个适配器作为仅主机适配器。启动虚拟机后,在终端输入“ifconfig”命令,您可以看到仅主机适配器的 ip4 地址(在 Windows 中为以太网适配器 Virtualbox Host-Only Network)。当您尝试在 windows 和 ubuntu 中输入该地址时,它会显示结果。

    另外,192.168.56.1 地址是我 PC 中的 Windows Virtualbox Host-Only 网络 IPv4 地址。

    【讨论】:

      【解决方案2】:

      我相信 NAT 适配器不允许主机和来宾之间直接连接,为此您需要第二个 Host-only Adapter

      请参阅this link 以获得很好的解释。

      【讨论】:

        猜你喜欢
        • 2010-11-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-11
        • 1970-01-01
        • 2014-12-29
        • 1970-01-01
        • 2021-09-24
        相关资源
        最近更新 更多