使用 TCP/IP 从虚拟机连接到另一个 [英] Connecting using TCP/IP from a virtualbox to another

查看:46
本文介绍了使用 TCP/IP 从虚拟机连接到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 2 台不同的机器在虚拟机上运行 ubuntu,我正在尝试在一台机器上运行服务器并从另一台机器连接客户端.但是,由于虚拟机提供的 IP 地址非常奇怪,即 10.x.x.x ,我无法连接.我设法在同一台虚拟机上以 ./server 和另一个 ./client localhost 2017 的形式运行这两个程序,但不在不同的机器上.. 我正在尝试使用 ./client 10.xxx 2017 和产生的错误是错误连接.我还应该补充一点,当我检查时,据说虚拟机上的两台机器具有相同的 IP 地址..有什么帮助吗?

I have 2 different machines running ubuntu on virtual box and i'm trying to run a server on one machine and connect with the client from another machine . However I am not able to connect due to the fact that the IP adress given from the virtual box machine is very strange that is 10.x.x.x . I am managing to run both programs one as ./server and the other ./client localhost 2017 on the same virtual box machine however not on different machines .. I am trying to run the client using ./client 10.x.x.x 2017 and the resulting error is error connecting . I should also add that both machines on virtual box are said to have the same IP address when I checked.. any help please ?

推荐答案

默认情况下 VirtualBox 配置 NAT 网络.您需要在桥接模式下设置您的适配器,并确保您的路由器可以为两个虚拟机提供 IP 地址.

By default VirtualBox configures NAT networking. You need to setup your addaptors in bridge mode and make sure your router can provide both VMs with IP addresses.

您可以在此处阅读更多相关信息.

You can read more about it HERE.

这篇关于使用 TCP/IP 从虚拟机连接到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆