Skip to content

Instantly share code, notes, and snippets.

@leemour
Created November 23, 2015 12:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leemour/06232d23eae462b5bda9 to your computer and use it in GitHub Desktop.
Save leemour/06232d23eae462b5bda9 to your computer and use it in GitHub Desktop.
Iptables redirect port 3000 to port 80
# sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 3000
# sudo iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 80 -j REDIRECT --to-ports 3000
sudo iptables -t nat -A OUTPUT -d localhost -p tcp --dport 80 -j REDIRECT --to-port 3000
# Save iptables to file
sudo bash -c "iptables-save -c > /etc/iptablesrc"
# Apply localhost redirect saved in iptablesrc on system start
# sudo bash -c "iptables-restore < /etc/iptablesrc"
alias iptrest='sudo bash -c "iptables-restore < /etc/iptablesrc"'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment