Skip to content

Instantly share code, notes, and snippets.

@benkahle
Last active August 29, 2015 14:04
Show Gist options
  • Save benkahle/f25539344e4e9c47b3ec to your computer and use it in GitHub Desktop.
Save benkahle/f25539344e4e9c47b3ec to your computer and use it in GitHub Desktop.
Commands to set up port redirection on ubuntu
//list current rules
sudo iptables -t nat -L --line-numbers
//delete rule for port <n>
sudo iptables -t nat -D PREROUTING <n>
//redirect port 80 to port <n>
sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port <n>
//Save settings (need package iptables-persistent installed)
sudo iptables-save >/etc/iptables/rules.v4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment