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!