Clearing out all DNS records

Hi, need some help! I went to add my domain, but removed it so I could recreate it using a different initial DNS config. So that when Cloudflare scans for records it picks up the right ones. My other DNS settings create about 30 records, and using Cloudflare it's such a pain deleted multiple records! It seems Cloudflare only soft deletes when you click remove, which I hate. So when I re-add, it refuses to re-scan, and just pulls the soft deleted records, boo! How do I fix this? EDIT: I tried exporting a zone file from my registrar, and then importing to replace the records at creation time, but the cloudflare import functionality, on that page, is broken at the moment. It has trouble reading a valid zone file EDIT(2): I fixed the import by editing a record manualy before exporting, to make it work, but that only appends records, not replaces 😦 Now I have like 33 records
2 Replies
rubixibuc
rubixibucOP•5mo ago
So I saw there's API access to do this, but I think that's completely ridiculous! I just wrote some js to take care of it for me. Dropping here for future use
const sleep = (timeout = 3000) => new Promise(res => {
setTimeout(res, timeout)
})


(async () => {
for(record of document.querySelectorAll("[data-testid=dns-table-row-edit-link]")) {
record.click();
await sleep();
document.querySelector("[data-testid=dns-record-form-delete-button]").click()
await sleep();
document.querySelector("[data-testid=dns-delete-modal-confirm-button]").click()
}
})()
const sleep = (timeout = 3000) => new Promise(res => {
setTimeout(res, timeout)
})


(async () => {
for(record of document.querySelectorAll("[data-testid=dns-table-row-edit-link]")) {
record.click();
await sleep();
document.querySelector("[data-testid=dns-record-form-delete-button]").click()
await sleep();
document.querySelector("[data-testid=dns-delete-modal-confirm-button]").click()
}
})()
Chaika
Chaika•5mo ago
yea it's sad there's no easier way. Zones indeed are only soft deleted when you delete, would need to wait 7 days for all the config to be lost to readd fresh https://developers.cloudflare.com/dns/zone-setups/reference/domain-status/. Cloudflare does have a nice linux script for this in the docs: https://developers.cloudflare.com/dns/zone-setups/troubleshooting/delete-all-records/ or a util made by a community mvp: https://cloudflare-utils.cyberjake.xyz/ Eventually scripts like the one you made will break with dash changes
Want results from more Discord servers?
Add your server