Skip to content

Instantly share code, notes, and snippets.

@ei-grad
Created January 2, 2024 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ei-grad/a57d9f8844c52f2adb7b9ea6b4808ec9 to your computer and use it in GitHub Desktop.
Save ei-grad/a57d9f8844c52f2adb7b9ea6b4808ec9 to your computer and use it in GitHub Desktop.
Script to fetch list of all cloudflare DNS records
#!/bin/bash
cf_api_fetch() {
curl -s "https://api.cloudflare.com/client/v4/$1" \
-H "X-Auth-Email: $CLOUDFLARE_EMAIL" \
-H "X-Auth-Key: $CLOUDFLARE_API_KEY" \
| jq -r "$2"
}
for zone_id in $(cf_api_fetch "zones" '.result[] | .id'); do
cf_api_fetch "zones/$zone_id/dns_records" \
'
.result[] | (
.type
+ " " + .name
+ " " + .content
+ " proxied=" + (.proxied|tostring)
+ " ttl=" + (.ttl|tostring)
)
' &
done
wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment