Skip to content

Instantly share code, notes, and snippets.

@Placidina
Created November 14, 2019 00:18
Show Gist options
  • Select an option

  • Save Placidina/d64f18b063ed30d64d2b51ad9be71c1f to your computer and use it in GitHub Desktop.

Select an option

Save Placidina/d64f18b063ed30d64d2b51ad9be71c1f to your computer and use it in GitHub Desktop.
Port Forwarding
#!/bin/bash
if [ "$EUID" -ne 0 ]; then
echo >&2 "Sorry, you need to run this as root"
exit 1
fi
iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 32080
iptables -t nat -I OUTPUT -p tcp -o lo --dport 80 -j REDIRECT --to-ports 32080
iptables -A INPUT -i eth0 -p tcp --dport 443 -j ACCEPT
iptables -t nat -I PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 32443
iptables -t nat -I OUTPUT -p tcp -o lo --dport 443 -j REDIRECT --to-ports 32443
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment