Forked from ccharlton/cloudflare_firewall_bulk_ip_whitelist.sh
Created
July 31, 2020 15:20
-
-
Save junneshenning/e1cdfc5370dee107c30a313d7d536205 to your computer and use it in GitHub Desktop.
Cloudflare firewall bulk IP whitelist
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 | |
IPADDRESS=("123.123.123.124" "456.456.456.457" "890.890.890.891") | |
echo "Adding IP addresses to Cloudflare Firewall..." | |
echo '' | |
for i in "${IPADDRESS[@]}" | |
do | |
: | |
# do whatever on $i | |
echo $i | |
curl -X POST "https://api.cloudflare.com/client/v4/user/firewall/access_rules/rules" \ | |
-H "X-Auth-Email: [email protected]" \ | |
-H "X-Auth-Key: YOURPRIVATECLOUDFLAREAPIKEY" \ | |
-H "Content-Type: application/json" \ | |
--data '{"mode":"whitelist","configuration":{"target":"ip","value":"'$i'"},"notes":"Why this IP was added"}' | |
echo '' | |
done | |
echo '' | |
echo "Done adding IP addresses to Cloudflare Firewall" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment