Created
August 15, 2017 07:33
-
-
Save Kaali/277ab99015ac5d9a5a3a9bfaa34500ab to your computer and use it in GitHub Desktop.
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 | |
INTERFACE=ens33 | |
PROXY=proxy.local:8080 | |
if [[ "$EUID" -ne 0 ]]; then | |
echo "Please run as root" | |
exit 1 | |
fi | |
cleanup() { | |
iptables-save | grep -v -- 'ANYPROXY' | iptables-restore | |
} | |
trap cleanup TERM KILL QUIT EXIT HUP | |
sysctl -w net.ipv4.ip_forward=1 | |
iptables -t nat -N ANYPROXY | |
iptables -t nat -I PREROUTING 1 -j ANYPROXY | |
iptables -t nat -I OUTPUT 1 -j ANYPROXY | |
iptables -t nat -A ANYPROXY -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128 | |
iptables -t nat -A ANYPROXY -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 3128 | |
echo "Proxy started (C-C to quit)" | |
any_proxy -l :3128 -p=$PROXY |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment