Skip to content

Instantly share code, notes, and snippets.

@ABeltramo
Created December 15, 2016 13:12
Show Gist options
  • Save ABeltramo/8f321c6cc3fa8c5267cc1f9a09e2f90f to your computer and use it in GitHub Desktop.
Save ABeltramo/8f321c6cc3fa8c5267cc1f9a09e2f90f to your computer and use it in GitHub Desktop.
Cloudflare iptables
#!/bin/bash
# Only once setup:
# iptables -N cloudflare
# iptables -t filter -I INPUT -j cloudflare -p tcp -m multiport --dports http,https
iptables -F cloudflare
for i in `curl https://www.cloudflare.com/ips-v4`; do
iptables -A cloudflare -p tcp -s $i -m multiport --dports domain,http,https -j ACCEPT;
done
iptables -A cloudflare -j RETURN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment