Skip to content

Instantly share code, notes, and snippets.

@ArseniyShestakov
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArseniyShestakov/dc58074b87e5caf4d3a3 to your computer and use it in GitHub Desktop.
Save ArseniyShestakov/dc58074b87e5caf4d3a3 to your computer and use it in GitHub Desktop.
Different console tricks to remember
# Lazy TCP port forwarding on localhost
autossh -M 0 -f -N -R 34567:192.168.1.150:34567 localhost
## Proper port forwarding from server to internal subnet
# Allow forwarding on external interface (eth0)
iptables -A FORWARD --in-interface eth0 -j ACCEPT
# Add masquerade for internal OpenVPN interface (tun0)
iptables -t nat -A POSTROUTING --out-interface tun0 -j MASQUERADE
# Forward from public ip port 8080 to internal port 80
iptables -t nat -A PREROUTING -p tcp -i eth0 -m tcp --dport 8080 -j DNAT --to-destination 192.168.1.150:80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment