syntaxlexx / cloudflare-dns-mass-updater

Update CloudFlare DNS records in mass using a YAML file

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CloudFlare DNS Mass-Updater

A Cloudflare DNS updater tool to mass-update records

Getting Started

  • Install CloudFlare Tools.
  • 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 or zshrc file
export CLOUDFLARE_API_TOKEN=MyVeryLongToken

NB: remember to run source ~/.bashrc or source ~/.zshrc

Download DNS (YML)

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.

Updating the YML file

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.

Updating it, the Node way

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!

Upload Changes to CloudFlare DNS

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.

Credits

About

Update CloudFlare DNS records in mass using a YAML file

License:MIT License


Languages

Language:JavaScript 100.0%