Skip to content

Instantly share code, notes, and snippets.

@Mic92
Created July 20, 2016 11:45
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 Mic92/bc192331469104ce01cf5064503cb81b to your computer and use it in GitHub Desktop.
Save Mic92/bc192331469104ce01cf5064503cb81b to your computer and use it in GitHub Desktop.
Random source ip to work around rate limiting
#!/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