Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.