如何在不同计算机上运行的虚拟机上运行客户端服务器应用程序?

用户名

您好,我有两台笔记本电脑运行Ubuntu 16.04和Ubuntu 14.04。他们每个人都有一个运行Solaris 11的虚拟机。我想在一个虚拟机上运行一个服务器程序,在另一个笔记本电脑上的另一个虚拟机上运行客户端程序。这可能吗?

我尝试了Googling,但发现的只是有关在同一台计算机上连接虚拟机的信息。请提出如何做到这一点。

谢谢

编辑:我正在尝试在虚拟盒子上并使用我的家庭wifi。

水瓶座一号

从网络角度来看,您有两个选择:

  1. 很多NAT。默认情况下,我假设您的VM在任何虚拟化解决方案中都设置为使用NAT模式,这使操作起来有些棘手。可行,但棘手。

  2. 虚拟机也“桥接”到主机系统所在的实际网络上,这消除了NAT的麻烦。这是更简单的选择。



选项1:NAT模式下的VM网络

注意:我从没有使它可靠地工作过,我一直使用桥接模式,这种方式要可靠得多。

VMware和VBox都设置为允许NAT和端口转发。这一切都很好,很花哨,但这带来了一些麻烦。


虚拟机

除非您具有VMware Workstation Pro,否则无法轻松设置NAT端口转发。这是因为用于NAT端口转发的虚拟网络编辑器未随Workstation Player或较早的VMware Player软件版本一起提供。

假设您具有虚拟网络管理器/编辑器,但是在具有将作为“服务器”的VM的系统上执行以下操作:

(1)打开“虚拟网络管理器/编辑器”,然后选择一个带有“ NAT”的适配器作为“外部连接”列表。它看起来像此图所示:在此处输入图片说明

(2)选择“ NAT设置”,您将获得一个类似这样的窗口:

在此处输入图片说明

(3)在“端口转发”区域下,单击“添加”。您会看到一个像这样的窗口:

在此处输入图片说明

设置信息如下:

Host Port: Likely to be the same port you're having the Server listen on in the VM, but it can be something else if you want.

Type: TCP or UDP is dependent on your server and how it listens. Safe to assume TCP here, though, most active-connection server things are TCP.

IP Address: The IP address of the VM. You can get this with ip -4 addr list from inside the VM on the command line.

Virtual Machine Port: The port that the server application will be listening on.

Description: A description of what this port forward is for.

You'll probably have to shut off your VM temporarily, and restart the VMware services with sudo systemctl restart vmware so it reloads all the port forwarding/bridging rules.

(4) Start up the VM with the server on it. From the Client VM, make sure you tell the Client to connect to the IP Address of the computer that is running the Server VM (so if the laptop with the Server VM on it has IP address of 192.168.250.20, the Client VM's application should try and connect to 192.168.250.20.)

Note that this will not work in all cases, and I strongly recommend the use of Bridged mode instead.


VirtualBox

I have never gotten VBox NAT network port forwarding to behave. If you are using VBox, I strongly suggest you use Bridged mode instead of NAT. (While this doesn't clearly answer for VBox, I tried testing these Port Forwards from VBox and couldn't get it to work at all).

Not that I didn't try, but on 16.04, VirtualBox was not able to connect outbound to anything, and never set up any virtual network interfaces for NAT capabilities; I assumed then that it can't work right without Bridged but I can't find why it never brought up NAT capacity.



Option 2: VM Networking: Bridged Mode

You will need to run the VMs in "Bridged" mode and then use IP addresses from your own LAN/Wifi network that are assigned to the VMs (as a result of "bridged" allowing the VMs to connect to and look like they're on the actual network of the host computers).

Firstly, configure the VMs on both systems to use the "Bridged Network" mode. How this shows will be different from VM solution to VM solution, but it'll always say "Bridged" or similar (at least, in VMware or VBox). Make sure the device that you're "bridged" to is your preferred network card (wifi or ethernet), so you're properly going out to the right network with the VM for an IP address.

Secondly, reboot the VMs if they're already online. This should get them a brand new IP address from the same network as the host machines. (It should be in the same subnet range even).

Thirdly, point the client of the one VM to the IP of the server on the other VM. Because the networking is Bridged, it should just connect. You may have to tweak the VMs on the guests to make sure it permits connections though.

对于VM,就应该如此,并且它们应该能够互连而不会出现问题。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在客户端计算机上将 Windows 服务作为控制台应用程序运行

您可以在同一主机上运行客户端应用程序和服务器应用程序吗

如何在同一台计算机上同时运行Synergy客户端和Synergy服务器?

如何在同一主机上运行Angular 2客户端应用程序和节点服务器应用程序

无法使用本地计算机作为服务器在客户端运行桌面应用程序

如何在Docker容器内的本地计算机上运行的MySQL服务器用于DropWizard应用程序?

在运行OpenVPN服务器的计算机上启动/停止OpenVPN客户端(命令行)

在服务器端运行客户端 websocket 应用程序?

套接字服务器和套接字客户端Java-从位于不同计算机上的客户端检测服务器

为什么pyinstaller生成的cx_oracle应用程序可以在新的CentOS计算机上运行,而不能在安装了Oracle客户端的计算机上运行?

如何从实际计算机访问虚拟机上的django开发服务器

将PDF保存到服务器而不是客户端计算机上

从服务器打开客户端计算机上的网站

可以在客户端计算机上记录服务器的根目录

在Linux客户端计算机上挂载Samba共享(Linux服务器)

是否可以在同一台计算机上运行套接字服务器和套接字客户端?

发布应用程序后客户端计算机上的变量冲突问题

从Web窗体在客户端计算机上启动MS Word应用程序。(所有浏览器)

如何从服务器在客户端计算机中执行Java应用程序?

如何在Windows 7计算机上运行.Net Core Web应用程序?

如何在JAVA中运行服务器-客户端应用程序

如何使Java客户端使用套接字连接到不在我的计算机上的服务器?

如何在虚拟计算机上运行代码?

使应用程序在超高清计算机上运行

如何在连接字符串中添加数据目录以在客户端计算机上部署应用程序?

客户端计算机上的MySQLdb可以连接到服务器计算机上的数据库吗?

在不同时区在一台计算机上运行服务器

从另一台计算机访问虚拟机上的Web服务器

简单客户端服务器应用程序中的“ ...目标计算机主动拒绝了...”异常