Skip to content

Instantly share code, notes, and snippets.

@Deviad
Created September 13, 2017 06:58
Show Gist options
  • Save Deviad/a440186915e3fe01c81e170c44dd60ba to your computer and use it in GitHub Desktop.
Save Deviad/a440186915e3fe01c81e170c44dd60ba to your computer and use it in GitHub Desktop.
Socat Port Forwarding Examples
Example 1
socat TCP4-LISTEN:5010,reuseaddr,fork PROXY:109.185.139.177:www.zerohedge.com:80,proxyport=65103
In our case
ping www.zerohedge.com
34.199.177.156 is the ip of zerohedge.com
note it somewhere
echo "127.0.0.1 www.zerohedge.com" >> /etc/hosts
Port 5010 must be replaced with the real port used by the app, it's just a placeholder
socat TCP4-LISTEN:5010,reuseaddr,fork PROXY:109.185.139.177:34.199.177.156:80,proxyport=65103
This way we trick the OS into believing that our node is zerohedge and this way we do not have to rewrite code.
Parameters in the examples must be replaced accordingly.
Example 2
Example of socat listening to multiple ports:
echo -n 3392 3393 3394 | xargs -d ' ' -I% bash -c 'socat TCP4-LISTEN:%,fork TCP4:192.168.10.102:% &'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment