Created
November 27, 2017 18:30
-
-
Save lmlsna/0fe2f8d3e0eb61c237ea44ba0d598317 to your computer and use it in GitHub Desktop.
A Bash one-liner to whitelist Cloudflare's IPs in iptables.
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 | |
iptables -A INPUT -p tcp -m multiport --dports 80,443 -s $(for ip in $(curl -s https://www.cloudflare.com/ips-v4); do echo -n "$ip,"; done|head -c-1) -j ACCEPT | |
ip6tables -A INPUT -p tcp -m multiport --dports 80,443 -s $(for ip in $(curl -s https://www.cloudflare.com/ips-v6); do echo -n "$ip,"; done|head -c-1) -j ACCEPT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment