M
M
Maxim2021-07-27 09:51:07
linux
Maxim, 2021-07-27 09:51:07

How to connect a virtual machine from one local network to a computer from another local network via the Internet?

I have a Windows 10 laptop with VirtualBox installed. Ubuntu is installed on the virtual machine, which communicates with the host network through NAT.

The laptop is connected via Wi-Fi to the Internet through a router. Dynamic addresses are used between the laptop and the router on the network.

There is a computer with Windows 10, it is connected via Wi-Fi to the Internet through a router. The network between the computer and the router uses dynamic addresses. The router has a static Internet address.

This computer is connected via ethernet to an Ubuntu computer. This is a point-to-point connection using static addresses.

How can I SSH from an Ubuntu VM to an Ubuntu machine across multiple LANs and the Internet?

60ffb014cea11166788733.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Ruslan Fedoseev, 2021-07-27
@martin74ua

VPN server where there is a thread on the internet, connection from both computers to it, interaction with each other through vpn

A
Artem @Jump, 2021-07-27
curated by the

How can I SSH from an Ubuntu VM to an Ubuntu machine across multiple LANs and the Internet?
This requires a white IP address. No way without him.
Do you have it?
Ideally, the white IP should be on the router through which your Ubuntu virtual machine accesses the Internet.
Then it is enough to forward the desired port (22) and that's it.
Therefore, the only question is do you have a white IP address?

R
rPman, 2021-07-27
@rPman

In the diagram, the lower router has a static ip on the internet and it is on the right local network with the Ubuntu machine, and it has a static ip, you can’t imagine better.
On this router, you set up port forwarding (this is usually called a virtual private server) when connections from the Internet on the specified port are forwarded to a machine on the router's local network on the specified port, such as router: 1021 -> ubuntu: 21
Since the virtual machine with ubuntu is in the upper network through double nat (first the virtualbox router, then the router itself) goes online, then you connect to the second router using the port specified in the forwarding with a simple ssh.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question