Skip to content

Instantly share code, notes, and snippets.

@filipepgoes
Created September 2, 2016 17:09
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 filipepgoes/1e129d47ae66008d502ad6a2fb706eee to your computer and use it in GitHub Desktop.
Save filipepgoes/1e129d47ae66008d502ad6a2fb706eee to your computer and use it in GitHub Desktop.
Script to change Ubuntu ports
#!/bin/bash
PRIVATE_PORT=8080
PUBLIC_PORT=80
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root."
exit 1
fi
iptables -t nat -A PREROUTING -p tcp --dport $PUBLIC_PORT -j REDIRECT --to-port $PRIVATE_PORT
iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport $PUBLIC_PORT -j REDIRECT --to--ports $PRIVATE_PORT
echo "Done."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment