Created
October 23, 2023 02:32
-
-
Save supersonictw/24434c20ccb45f4cb687347c847d5f2f to your computer and use it in GitHub Desktop.
Flush Cloudlflare DNS records
This file contains 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 | |
# Flush Cloudlflare DNS records | |
CF_TOKEN="" | |
ZONE_ID="" | |
QUERY_RECORDS() { | |
curl -s -X GET https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records?per_page=500 \ | |
-H "Authorization: Bearer ${CF_TOKEN}" \ | |
-H "Content-Type: application/json" | |
} | |
REMOVE_RECORD() { | |
curl -s -X DELETE https://api.cloudflare.com/client/v4/zones/${ZONE_ID}/dns_records/$1 \ | |
-H "Authorization: Bearer ${CF_TOKEN}" \ | |
-H "Content-Type: application/json" | |
printf "\n" | |
} | |
QUERY_RECORDS | jq .result[].id | tr -d '"' | ( | |
while read id; do | |
REMOVE_RECORD $id & | |
done | |
) | |
wait |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment