Skip to content

Instantly share code, notes, and snippets.

@arastu
Last active July 16, 2018 12:34
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 arastu/8d2986afa21abd826979b374398fc92f to your computer and use it in GitHub Desktop.
Save arastu/8d2986afa21abd826979b374398fc92f to your computer and use it in GitHub Desktop.
# client ----> 1.1.1.1 --------> 2.2.2.2
# (relay) (dest)
sudo iptables -A FORWARD -d 2.2.2.2 -i ens160 -p udp -m udp --dport 500:500 -j ACCEP
sudo iptables -A FORWARD -d 2.2.2.2 -i ens160 -p udp -m udp --dport 4500:4500 -j ACCEPT
sudo iptables -t nat -A PREROUTING -d 1.1.1.1 -p udp -m udp --dport 500:500 -j DNAT --to-destination 2.2.2.2
sudo iptables -t nat -A PREROUTING -d 1.1.1.1 -p udp -m udp --dport 4500:4500 -j DNAT --to-destination 2.2.2.2
sudo iptables -t nat -A POSTROUTING -o ens160 -j MASQUERADE
sudo ufw allow 500/udp
sudo ufw allow 4500/udp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment