A Cloudflare DNS updater tool to mass-update records
- Install CloudFlare Tools.
- Download from the Releases page
- Generate an
api-token
from your CloudFlare Dashboard - Use the api-token in successive requests to the API
- Alternatively, set the following in your
bashrc
orzshrc
file
export CLOUDFLARE_API_TOKEN=MyVeryLongToken
NB: remember to run
source ~/.bashrc
orsource ~/.zshrc
Run the following command to download existing DNS config
NB: ensure you copy the
zone-id
from cloudflare dashboard unser the selected domain
cloudflare-utils --zone-id domain-zone-id dns-cleaner download
It will download dns-records.yml
on the current directory.
In the yml
file, every record block is structured in this way:
- id: egfoebfewfwfwef
keep: true
name: acelords.com
type: A
content: 127.0.0.1
Setting the keep: true
to keep: false
shall delete it form the CLoudFlare DNS.
Some of these records can be as many as 700+, and thus can be tedious doing it manually.
The file index.js
contains a variable named validDns
that accepts a string
of valid domain addresses
.
- Update it as you deem fit.
- Once done, run
node index.js
- The 'fixed' DNSs will be located under a new file
dns-fixed.yml
. - do a quick check on the
dns-fixed.yml
file to confirm it's good - copy-paste its contents back to
dns-records.yml
. (There's a new--filename
you can check on how to use it in the docs. Am just lazy as it's a one-off thing)
Time to upload the changes!
Run the following command to update the DNS records. This might take a while to complete.
cloudflare-utils --zone-id my-domain-zone-id dns-cleaner upload
You may read up more on the docs for extra options like a --dry-run
or something.