Skip to content

Instantly share code, notes, and snippets.

@Kaali
Created August 15, 2017 07:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kaali/277ab99015ac5d9a5a3a9bfaa34500ab to your computer and use it in GitHub Desktop.
Save Kaali/277ab99015ac5d9a5a3a9bfaa34500ab to your computer and use it in GitHub Desktop.
#!/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