Forward traffic to specific IP via SSH SOCKS tunnel

1.5k views Asked by At

I'm able to SSH into 223.32.11.43 and cURL other servers on it's local network.

This works when I'm SSH'ed into :

curl -d '{my: parameter}' -H "Content-Type: application/json" 10.0.30.10
{code:200}

On a remote server I've setup a SOCKS tunnel with:

ssh -f -N -D 9090 [email protected]

I've tried to setup iptables so I can cURL internal servers on the same network as the remote server:

iptables -t nat -A OUTPUT -s 10.0.30.10 -p tcp --dport 80 -j DNAT --to-destination 223.32.11.43

But it seems to fail, at least it times out with I try to cURL:

curl -d '{my: parameter}' -H "Content-Type: application/json" 10.0.30.10
...timeout

What do to, so I can do the same cURL on my remote server?

1

There are 1 answers

2
drew010 On BEST ANSWER

This worked for me:

From your remote computer, set up the SOCKS SSH tunnel to the remote server:

ssh -D 9090 -f -C -q -N [email protected]

From the remote computer, issue a request over the tunnel:

curl -d '{my: parameter}' -H "Content-Type: application/json" \
--socks5-hostname remote.ip:9090 10.0.30.10