How to connect two VMs, each one in a different laptop: alternative solutions

Discussions related to using VirtualBox on Linux hosts.
Post Reply
Luis_0099
Posts: 4
Joined: 15. Dec 2022, 11:16

How to connect two VMs, each one in a different laptop: alternative solutions

Post by Luis_0099 »

Hi everyone,

This is my first post, so I am not sure whether this is the right section of the forum.

I have a doubt about Virtualbox and its connectivity that, I think, it has already been answered in several threads. However I don't know whether the solution I have found is the only one. My question is this:

I have two laptops, each one running a VM. Laptops and VM are Ubuntu-based, and both laptops are in the same network. The problem I need to solve is that I have to communicate both VMs. The solution I have found is setting the VMs networks in "bridge mode", so that both VMs are "seen" by the router like two physical computers. In other words, in my network I would have four machines: two would be real and two virtual.

However, and for completeness reasons, I need to know if there is any other possible solution. I remember a teacher that told me that "you don't really understand a problem if you are not capable of finding, al least, three different solutions". Currently I only know one solution for this problem.

Best regards,
Luis
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: How to connect two VMs, each one in a different laptop: alternative solutions

Post by mpack »

Bridging is the solution I would choose, though the details would depend on what you mean by "connecting". That could mean anything from ability to email, right through to full network participation. For full network participation on a physical network, bridging is the only solution provided by VirtualBox. If your tutor can suggest two others then by all means let him!
Luis_0099
Posts: 4
Joined: 15. Dec 2022, 11:16

Re: How to connect two VMs, each one in a different laptop: alternative solutions

Post by Luis_0099 »

Thank you for answering.

Luis
bbender-v
Posts: 12
Joined: 19. Apr 2013, 04:12

Re: How to connect two VMs, each one in a different laptop: alternative solutions

Post by bbender-v »

For the two VMs to see just each other, as if they were all alone on an isolated ethernet segment, there's also the UDP tunnel network option: https://www.virtualbox.org/manual/UserM ... udp_tunnel

Setting that up is like stringing an ethernet cable between the two virtual adapters of the VMs. There's no provided DHCP, no external routes, just whatever the two VMs bring to the party. If you wanted them to also be able to get out to the rest of the world as well, then one or both VMs would also need an additional virtual adapter, that one either NAT or bridged.
Luis_0099
Posts: 4
Joined: 15. Dec 2022, 11:16

Re: How to connect two VMs, each one in a different laptop: alternative solutions

Post by Luis_0099 »

bbender-v wrote:For the two VMs to see just each other, as if they were all alone on an isolated ethernet segment, there's also the UDP tunnel network option: https://www.virtualbox.org/manual/UserM ... udp_tunnel

Setting that up is like stringing an ethernet cable between the two virtual adapters of the VMs. There's no provided DHCP, no external routes, just whatever the two VMs bring to the party. If you wanted them to also be able to get out to the rest of the world as well, then one or both VMs would also need an additional virtual adapter, that one either NAT or bridged.

Wow, thank you bbender-v. I feel curious, Is it possible to extend that solution to a scenario with three (or more) VMs, each one running on its own host?

Best.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: How to connect two VMs, each one in a different laptop: alternative solutions

Post by scottgus1 »

See Virtualbox Networks: In Pictures
Luis_0099 wrote:in my network I would have four machines: two would be real and two virtual.
This restriction of the OP (having the 2 physical PCs in the network with the 2 VMs) makes UDPTunnel not a solution to the stated problem, unfortunately. UDPTunnel is for connecting only two VMs, ideally on two different hosts. The VMs would be in their own private network that the hosts cannot access. Bridged includes the hosts in the network. Bridged fits the OP's restriction.

If the two VMs are in the same host, then Internal can be used a lot easier than UDPTunnel.

If Luis meant to only connect the VMs and not include the hosts in the traffic, then the OP did not state the problem accurately.
Luis_0099 wrote:Is it possible to extend that solution to a scenario with three (or more) VMs, each one running on its own host?
UDPTunnel only connects 2 VMs. You'd need a VM with an OS acting as an unmanaged switch: each UDPTunnel from the other VMs on other hosts would connect to that unmanaged switch VM. A VM on the same host as the unmanaged switch VM could use Internal to the unmanaged switch VM, instead of UDPTunnel. I have not found an OS that can act as an unmanaged switch. I have tried pfSense and Linux bridging, and have been unable to make them work.
Luis_0099
Posts: 4
Joined: 15. Dec 2022, 11:16

Re: How to connect two VMs, each one in a different laptop: alternative solutions

Post by Luis_0099 »

scottgus1 , thank you very much for your answer.

Regards.
Post Reply