Created
November 14, 2019 00:18
-
-
Save Placidina/d64f18b063ed30d64d2b51ad9be71c1f to your computer and use it in GitHub Desktop.
Port Forwarding
This file contains hidden or 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 | |
| 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