Created
May 3, 2021 04:04
-
-
Save pankpan/3d22c0e1311ef06366ba04903543674f to your computer and use it in GitHub Desktop.
iptables security policy for Cloudflare
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 -F | |
iptables -P INPUT DROP | |
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT | |
iptables -A INPUT -i lo -j ACCEPT | |
for IP in `curl -s https://www.cloudflare.com/ips-v4` | |
do | |
iptables -A INPUT -s $IP -p tcp -m multiport --dport 80,443 -j ACCEPT | |
done | |
# IPv6 | |
ip6tables -F | |
ip6tables -P INPUT DROP | |
ip6tables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT | |
for IP in `curl -s https://www.cloudflare.com/ips-v6` | |
do | |
ip6tables -A INPUT -s $IP -p tcp -m multiport --dport 80,443 -j ACCEPT | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment