I have a
- Local computer (behind NAT).
- An intermediate server which is publicly accessible and has a
fixed IP address. - Remote computer (behind NAT and not the same as local computer).
I’d like to temporarily share access to a website on the local network via the local computer and an intermediate server using SOCKS/SSH, so that a remote computer can view it. Is this possible when both the remote computer and the local computer are behind NAT? If yes, how?
NAT - Static Public IP - NAT
Local Network <- Local Computer - Intermediate Server - Remote Computer
I know I can do this with ngrok and similar services, but I would like to learn how to do it myself using SSH and SOCKS.
Bounty: I will give preference to answers with example code and explanations on how to do it. Thank you.
Best Answer
If you want/need dynamic port forwarding you could try the following configuration:
l-user : user on my-local-computer
i-user : user on intermediate
intermediate : ip address of the intermediate host
on my-local-computer:
on the-remote:
The remote port forwarding between
my-local-computer
andintermediate
must exist before the connection fromthe-remote
is initiated.In this configuration
the-remote
acts as an SOCKS5 proxy on port 3456 and forwards the traffic via theintermediate
tomy-local-comuter
where it should end in your local lan.