0

I`m facing the following problem:

Lets call my machine the PC-1 and a remote machine which i want to access, the PC-2. PC-1 and PC-2 are in different networks, and both are behind a NAT.

To achieve connecting PC-1 to PC-2, i used a third machine with a valid external IP (A VPS) running socat.

So, PC-2 is running a VNC server on port 5900. To create the tunnel, i used socat with this syntax:

socat tcp-l:10000 tcp4:localhost:5900

And on the VPS:

socat tcp-l:20000 tcp-l:10000

So, if i connect PC-1 using the VPS IP Address and port 20000, the connection works, and i receive the VNC session from PC-2 My questions are:

1:Is there a more practical way to do this? Did i thought too far?

2:When the session finishes, i can't connect again until i restart socat in both machines. Is there a way to keep the sockets listening again? (I know about the fork and reuseaddr, but how to use them?)

Thanks in advance!

Nathan
  • 1
  • 1
    Such tunneling is usually done with `ssh -R` (can be automatized with `autossh`). Compare [this question](https://superuser.com/q/1566894/432690). – Kamil Maciorowski Nov 10 '20 at 18:17
  • socat for forwarding vnc through the internet is a bad idea because vnc is totally insecure. A secure tunnel via ssh port forwarding is the preferred solution (forwarding only while ssh is active). – Robert Nov 10 '20 at 18:29
  • Sure. I'll try using SSH instead. Thanks! – Nathan Nov 12 '20 at 14:09

0 Answers0