Skip to content

Instantly share code, notes, and snippets.

@eaguad1337
Created October 22, 2018 14:11
Show Gist options
  • Save eaguad1337/59cb07d1d21421245082b87878182a8e to your computer and use it in GitHub Desktop.
Save eaguad1337/59cb07d1d21421245082b87878182a8e to your computer and use it in GitHub Desktop.
UFW Whitelist Cloudflare
#!/bin/sh
# @author Eduardo Aguad <[email protected]>
cd /tmp
wget https://www.cloudflare.com/ips-v4 -O ips-v4-$$.tmp
wget https://www.cloudflare.com/ips-v6 -O ips-v6-$$.tmp
for cfip in `cat ips-v6-$$.tmp`; do ufw allow from $cfip to any port 443 proto tcp; done
for cfip in `cat ips-v4-$$.tmp`; do ufw allow from $cfip to any port 443 proto tcp; done
for cfip in `cat ips-v4-$$.tmp`; do ufw allow from $cfip to any port 80 proto tcp; done
for cfip in `cat ips-v6-$$.tmp`; do ufw allow from $cfip to any port 80 proto tcp; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment