Skip to content

Instantly share code, notes, and snippets.

@FreeFly19
Last active March 6, 2023 02:27
Show Gist options
  • Save FreeFly19/3289ba9c901e3190b40a54e7f957ab4c to your computer and use it in GitHub Desktop.
Save FreeFly19/3289ba9c901e3190b40a54e7f957ab4c to your computer and use it in GitHub Desktop.
Port forwarding + ovpn
client
# put the line below to disable tunneling outcoming trafic
route-nopull
....
export DEST_IP=10.8.0.139
export DEST_PORT=5000
export LOCAL_EXPOSE_PORT=80
sudo iptables -t nat -A PREROUTING -p tcp -i eth0 --dport $LOCAL_EXPOSE_PORT -j DNAT --to-destination $DEST_IP:$DEST_PORT
sudo iptables -A POSTROUTING -t nat -p tcp -d $DEST_IP --dport $DEST_PORT -j MASQUERADE
sudo iptables -A FORWARD -p tcp -d $DEST_IP --dport $DEST_PORT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment