Created
September 6, 2020 14:21
-
-
Save rojenzaman/80d4f8f0aa34180efc17c0150f1b6dfa to your computer and use it in GitHub Desktop.
firewalld rules for cloudflare cdn IPs (Red Hat, CentOS, Fedora)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
curl https://www.cloudflare.com/ips-v4 > .ips-v4 | |
curl https://www.cloudflare.com/ips-v6 > .ips-v6 | |
firewall-cmd --new-zone=cloudflare --permanent | |
firewall-cmd --reload | |
for i in `<.ips-v4`; do firewall-cmd --zone=cloudflare --add-source=$i; done | |
for i in `<.ips-v6`; do firewall-cmd --zone=cloudflare --add-source=$i; done | |
firewall-cmd --zone=cloudflare --add-port=80/tcp | |
firewall-cmd --zone=cloudflare --add-port=443/tcp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cloudflare has changed the way https://www.cloudflare.com/ips-v4 and https://www.cloudflare.com/ips-v6 works, redirecting to https://www.cloudflare.com/ips-v4/ and https://www.cloudflare.com/ips-v4/
Adjust your curl commands to
or use the url with trailing slash.
Cloudflare may or may update this, we'll see.