0

I would like to connect a virtualbox computer to a local service on a remote computer. I can connect to local services, but the remote one, I have a problem because on the destination, the service runs in a local LAN.

Here is a graphic of the 3 computer and two interfaces on the 3rd computer. I want to connect to 10.0.0.8:200 since the service I want to connect to only runs on that local network on the remote computer.

+--------------------+
|                    |
|  VirtualBox        |
|  192.168.11.11:200 |
|                    |
+-----+--------------+
      |
      v
+--------------------+
|                    |
|  Local Computer    |
|  192.168.11.41:200 |
|                    |
+-----+--------------+
      |
      v
+--------------------+
|                    |
|  Remote Computer   |
|  8.8.8.8           |    <- I can connect here
|                    |
|  10.0.0.8:200      |    <- how do I connect here?
|                    |
+--------------------+

I'm able to open a tunnel between Local Computer and Remote Computer, but that does not give me a way to connect to the service on local network 10.0.0.8.

What I have so far is the SSH tunnel between the Local Computer and the Remote Computer. I can otherwise connect between the VirtualBox and Local Computer (I have a bridged network setup with works as expected.)

ssh -L 200:8.8.8.8:200 example.com

So what I'm missing is a connection between 8.8.8.8 and 10.0.0.8. How do I create a tunnel/proxy between the two which makes service on 10.0.0.8:200 available to my Local Computer?

7
  • Have you tried running ssh -L 200:10.0.0.8:200 8.8.8.8 on your local computer? That should create a tunnel from your local computer to the service via the remote computer. You should then be able to access that service from your VM via the host machine (local computer).
    – igal
    Sep 29, 2019 at 23:36
  • Isn't 8.8.8.8 Google's DNS server? Sep 29, 2019 at 23:55
  • @DavidDai I did not want to disclose my IP. :-) Sep 29, 2019 at 23:56
  • Ok I'm assuming 8.8.8.8 is the same as example.com. Then what you need to do is simply ssh -L 200:10.0.0.8:200 example.com. That means connections to localhost:200 will be forwarded to 10.0.0.8:200 on the remote host, which is where your program listens for connection. Sep 30, 2019 at 0:00
  • 1
    Are you trying to connect to localhost:200 or your-local-ip:200? If the latter, you may want to try ssh -L 0.0.0.0:200:10.0.0.8:200 example.com. Sep 30, 2019 at 0:11

1 Answer 1

2

First, there is an obvious error in your command. Your program only runs on the local network, but you are forwarding connection to the public IP using -L 200:8.8.8.8:200. So you should use -L 200:10.0.0.8:200 instead.

Second, by using -L 200:10.0.0.8:299, ssh client will only listen on localhost:200 by default. This behavior can be configured by using the GatewayPorts option. To explicitly tell ssh client to accept connection from other hosts you can use -L 0.0.0.0:10.0.0.8:200. From man ssh_config:

     GatewayPorts
             Specifies whether remote hosts are allowed to connect to local forwarded ports.  By default, ssh(1) binds local port forwardings to the loopback address.  This
             prevents other remote hosts from connecting to forwarded ports.  GatewayPorts can be used to specify that ssh should bind local port forwardings to the wild‐
             card address, thus allowing remote hosts to connect to forwarded ports.  The argument must be yes or no (the default).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .