cloud-dns.sh 715 B

12345678910111213141516171819202122
  1. #!/bin/bash
  2. read -p "Enter Cloudflare DNS Token:" TOKEN
  3. read -p "Enter Cloudflare ZONE ID:" ZONE_ID
  4. # EMAIL=jorjanseenearlbade@gmail.com
  5. # KEY=48f416ac6a55e0ff8525812f3480edbb1ca8f
  6. # Replace with
  7. # -H "X-Auth-Email: ${EMAIL}" \
  8. # -H "X-Auth-Key: ${KEY}" \
  9. # for old API keys
  10. curl -s -X GET https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records?per_page=1000 \
  11. -H "Authorization: Bearer ${TOKEN}" \
  12. -H "Content-Type: application/json" | jq .result[].id | tr -d '"' | (
  13. while read id; do
  14. curl -s -X DELETE https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records/${id} \
  15. -H "Authorization: Bearer ${TOKEN}" \
  16. -H "Content-Type: application/json"
  17. done
  18. )