Last active
May 20, 2017 08:06
-
-
Save sonnygauran/e667a9d6c6180ee5ae4619206cbac2f8 to your computer and use it in GitHub Desktop.
Import IP v4 and v6 addresses from cloudflare https://github.com/Paul-Reed/cloudflare-ufw/blob/master/cloudflare-ufw.sh
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 | |
DIR="$(dirname $(readlink -f $0))" | |
cd $DIR | |
wget https://www.cloudflare.com/ips-v4 -O ips-v4.tmp | |
wget https://www.cloudflare.com/ips-v6 -O ips-v6.tmp | |
mv ips-v4.tmp ips-v4 | |
mv ips-v6.tmp ips-v6 | |
for cfip in `cat ips-v4`; do ufw allow from $cfip; done | |
for cfip in `cat ips-v6`; do ufw allow from $cfip; done | |
ufw reload > /dev/null | |
# OTHER EXAMPLE RULES | |
# Examples to retrict to port 80 | |
#for cfip in `cat ips-v4`; do ufw allow from $cfip to any port 80 proto tcp; done | |
#for cfip in `cat ips-v6`; do ufw allow from $cfip to any port 80 proto tcp; done | |
# Examples to restrict to port 443 | |
#for cfip in `cat ips-v4`; do ufw allow from $cfip to any port 443 proto tcp; done | |
#for cfip in `cat ips-v6`; do ufw allow from $cfip to any port 443 proto tcp; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment