Created
September 2, 2016 17:09
-
-
Save filipepgoes/1e129d47ae66008d502ad6a2fb706eee to your computer and use it in GitHub Desktop.
Script to change Ubuntu ports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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