Delete all the DNS records in a domain in Cloudflare.
Go to file
2022-06-01 20:39:58 +05:30
.gitignore added DNS export files to gitignore 2022-05-31 23:06:03 +05:30
apicalls.py formatting and cleanup 2022-06-01 18:07:05 +05:30
app.py renamed API Key to API Token 2022-06-01 20:39:58 +05:30
config_sample.json renamed API Key to API Token 2022-06-01 20:39:58 +05:30
LICENSE Initial commit 2022-05-24 13:08:14 +00:00
Pipfile pipenv setup 2022-05-26 23:45:05 +05:30
Pipfile.lock pipenv setup 2022-05-26 23:45:05 +05:30
README.md added instructions 2022-06-01 20:22:08 +05:30

cloudflare-delete-all-dns-records

Delete all the DNS records in a domain in Cloudflare.

This program will delete all the DNS records in a given domain. Before deletion, it'll also take a backup of the existing DNS records and save it as a .txt file in BIND format.

Prerequisites

  • Python 3

  • Pip

    sudo apt install python3-pip

  • Python requests library

    pip install requests

  • CloudFlare API key

    You need a CloudFlare API key with access to edit zone DNS access for the domain:

    1. Go to your Cloudflare profile and then API Tokens
    2. Click on Create Token
    3. You can use the template Edit Zone DNS
    4. Enter the of the domain(s) you want to delete DNS from in Zone Resources
    5. Click Continue to summary and the Create Token
    6. You should get an API Token now.

Running the program

  1. Download and extract the zip file or Clone this repository:

    git clone https://git.pavakpaul.com/pavak/cloudflare-delete-all-dns-records.git

  2. cd to the directory:

    cd cloudflare-delete-all-dns-records

  3. Run app.py using python3 and follow the instructions

    python3 app.py

Using a config file to pass the API credentials

If you want to delete all the DNS records from multiple domains, it is a good idea to use a single token for mutiple domains. In that case, you can use save your credentials in config.json. Simply rename config_sample.json to config.json: mv config_sample.json config.json and save your configuration there. To load the config file, simply pass the argument loadconfig:

python3 app.py loadconfig

You still can't delete DNS from multiple domains to reduce accidental removals of DNS. To be safe, it's always a good idea to just create a token for a single domain.