Skip to content

Instantly share code, notes, and snippets.

@antipatico
Created September 9, 2018 09:22
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 antipatico/3bc4cc2769ba4e16951e39ca468e8572 to your computer and use it in GitHub Desktop.
Save antipatico/3bc4cc2769ba4e16951e39ca468e8572 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Created by antipatico (antipatico.ml)
# Download the latest cloudflare's IPv4 ranges and create an ipset
# named "cloudflare" you can later use in your iptables rules.
IPSV4=$(mktemp)
wget --quiet -O $IPSV4 https://www.cloudflare.com/ips-v4
ipset destroy cloudflare
ipset create cloudflare hash:net
while read -r range; do
ipset add cloudflare $range
done < $IPSV4
rm $IPSV4
ipset list cloudflare
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment