Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Cloudflare firewall bulk IP whitelist
#!/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: you@example.com" \
-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 can’t perform that action at this time.