I have a server in my home network (cannot port forward) and a VPS on the WAN. I need requests on a certain port, to, not from, the VPS to be forwarded to my home server. I have an SSH tunnel which works fine if I send the request to
localhost on VPS. However I want requests forwarded to VPS's
localhost from internet be sent to my home server through the tunnel. And it needs to be bi-directional.
I have seen this question, however it doesn't work for me. It is quite possible that I did something incorrectly.
My exact procedure:
a, my home server, I ran this command to set up the tunnel:
ssh -v -N -R 2222:localhost:22 firstname.lastname@example.org
I ran the following command on server
iptables -t nat -A PREROUTING -p tcp --dport 2223 -j DNAT --to-destination 127.0.0.1:2222
And tried to
ssh from another machine:
ssh email@example.com -p 2223
GatewayPorts yes in
sshd_config however I am still finding the same problem:
ssh: connect to host server-b.com port 2223: Connection refused.