Last active
April 25, 2020 03:29
-
-
Save jschpp/d882e83f6fa3d8201ce3 to your computer and use it in GitHub Desktop.
script to add all cloudflare IPs to 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/sh | |
exec > /var/log/cloudflare.log 2>&1 | |
set -x | |
for ip in $(curl -s https://www.cloudflare.com/ips-v4); do /usr/sbin/iptables -I INPUT -p tcp -m multiport --dports http,https -s "$ip" -j ACCEPT; done | |
for ip in $(curl -s https://www.cloudflare.com/ips-v6); do /usr/sbin/ip6tables -I INPUT -p tcp -m multiport --dports http,https -s "$ip" -j ACCEPT; done |
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/sh | |
[Unit] | |
Description=Add cloudflare ips to iptables | |
After=network.target | |
[Service] | |
Type=simple | |
ExecStart=/usr/bin/sh /usr/local/src/cloudflare-ip.sh | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment