Created
July 20, 2016 11:45
-
-
Save Mic92/bc192331469104ce01cf5064503cb81b to your computer and use it in GitHub Desktop.
Random source ip to work around rate limiting
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/sh | |
set -e | |
IF=${IF:-eth0:avahi} | |
for i in $(seq 1 30); do | |
ip addr add "169.254.75.$i/16" dev $IF scope link || true | |
done | |
iptables -t nat -F RANDSRC || iptables -t nat -N RANDSRC | |
iptables -t nat -D POSTROUTING -p tcp --dport 80 -j RANDSRC || true | |
iptables -t nat -I POSTROUTING -p tcp --dport 80 -j RANDSRC | |
ip=$(getent hosts loadbalancer.local | awk '{print $1}') | |
for i in $(seq 30 -1 2); do | |
iptables -t nat -A RANDSRC -d "$ip" -m statistic --mode nth --every "$i" --packet 0 -j SNAT --to-source 169.254.75.$i | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment