Skip to content

Instantly share code, notes, and snippets.

@AlexanderMatveev
Last active March 27, 2023 09:22
Show Gist options
  • Save AlexanderMatveev/0fef4ece27f57c1f17fd91c2ad478674 to your computer and use it in GitHub Desktop.
Save AlexanderMatveev/0fef4ece27f57c1f17fd91c2ad478674 to your computer and use it in GitHub Desktop.
Whitelist Cloudflare with ufw
#!/bin/bash
for x in $(curl https://www.cloudflare.com/ips-v4)
do
ufw allow proto tcp from $x to any port 80,443 comment "cf4 $(date '+%Y-%m-%d')"
done
for x in $(curl https://www.cloudflare.com/ips-v6)
do
ufw allow proto tcp from $x to any port 80,443 comment "cf6 $(date '+%Y-%m-%d')"
done
ufw status numbered
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment