Created
August 4, 2018 20:39
-
-
Save ccharlton/216dd8280e8449a9c3ac460a91c682d0 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
You need to run this shell script with bash command, not sh command