Cloudflare API- bash script to block IP address in firewall

 

Cloudflare API bash script to block IP address in firewall

#!/bin/bash
zones =
email =
authkey =
id =
org_name =
notes =

for i in `cat ips.txt`; do
curl -sSX POST “https://api.cloudflare.com/client/v4/zones/$zones/firewall/access_rules/rules” -H “X-Auth-Email: $email” -H “X-Auth-Key: $authkey” -H “Content-Type: application/json” –data “{\”mode\”:\”block\”,\”scope\”:{\”id\”:\”$id\”,\”name\”:\”$org_name\”,\”type\”:\”organization\”},\”configuration\”:{\”target\”:\”ip\”,\”value\”:\”$i\”},\”notes\”:\”$notes\”}” ;
echo “\n”
echo “IP $i blocked in Cloudflare”
echo “\n”
done