Created
January 2, 2024 14:59
-
-
Save ei-grad/a57d9f8844c52f2adb7b9ea6b4808ec9 to your computer and use it in GitHub Desktop.
Script to fetch list of all cloudflare DNS records
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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