Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save junneshenning/e1cdfc5370dee107c30a313d7d536205 to your computer and use it in GitHub Desktop.
Save junneshenning/e1cdfc5370dee107c30a313d7d536205 to your computer and use it in GitHub Desktop.
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: [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