GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - BaseMax/cloudflare-dns-ip-migrator-python: A simple Python CLI tool to bulk update DNS A records in your Cloudflare account, replacing an old IP address with a new one across multiple zones.

BranchesTags
Open more actions menu

Latest commit

 

History

10 Commits
10 Commits

Folders and files

NameName
Last commit message
Last commit date
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
cloudflare_dns_migrator.py
cloudflare_dns_migrator.py
 
 
requirements.txt
requirements.txt
 
 

Repository files navigation

cloudflare-dns-ip-migrator

A simple Python CLI tool to bulk update DNS A records in your Cloudflare account, replacing an old IP address with a new one across multiple zones.

Features

  • Connects securely to Cloudflare via API Token.
  • Auto-paginates through all your zones (domains).
  • Filters DNS records by type and current IP value.
  • Supports dry-run mode for safe previews.
  • Outputs results in human-readable or JSON format.
  • Verbose logging for debugging.

Prerequisites

  • Python 3.7 or newer
  • A Cloudflare API Token with permissions:
    • Zone:Read
    • DNS:Edit
  • pip to install dependencies

Testing API Key

curl -X GET "https://api.cloudflare.com/client/v4/user/tokens/verify" \
     -H "Authorization: Bearer WRxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
     -H "Content-Type:application/json"

Installation

  1. Clone this repository:

    git clone https://github.com/BaseMax/cloudflare-dns-ip-migrator.git
    cd cloudflare-dns-ip-migrator
  2. Install required packages:

    pip install -r requirements.txt
  3. Ensure your API token is set in the environment:

    export CF_API_TOKEN="your_cloudflare_api_token"

Usage

The main script is cloudflare_dns_migrator.py. Run it with the following options:

python cloudflare_dns_migrator.py \  
  --old-ip 65.21.1.28 \  
  --new-ip 95.217.195.92 \  
  --type A \               # DNS record type (default: A)
  --zone example.com \     # (Optional) Limit to specific zones
  --dry-run \              # (Optional) Preview changes without applying
  --verbose \              # (Optional) Enable debug logging
  --json                   # (Optional) Output results as JSON

Examples

  • Dry run replacing A records across all zones:

    python cloudflare_dns_migrator.py --old-ip 1.2.3.4 --new-ip 5.6.7.8 --dry-run
  • Update only in example.com and test.org:

    python cloudflare_dns_migrator.py \
      --old-ip 1.2.3.4 \
      --new-ip 5.6.7.8 \
      --zone example.com \
      --zone test.org
  • Verbose JSON output:

    python cloudflare_dns_migrator.py \
      --old-ip 1.2.3.4 --new-ip 5.6.7.8 \
      --verbose --json

Configuration Flags

Flag Description
-o, --old-ip (Required) Old IP address to be replaced.
-n, --new-ip (Required) New IP address to set.
-r, --type DNS record type (A, AAAA, CNAME, TXT). Default: A
-z, --zone Limit to specific zone(s). Repeatable for multiple domains.
--dry-run Preview changes without making updates.
--verbose Enable detailed debug logging.
--json Output results in JSON format.

Contributing

Contributions, issues, and feature requests are welcome! Feel free to:

  • Open an issue to report bugs or request features.
  • Fork the repository and submit a pull request.

Please adhere to the existing code style and write clear commit messages.

License

This project is licensed under the MIT License

© 2025 Max Base.

About

A simple Python CLI tool to bulk update DNS A records in your Cloudflare account, replacing an old IP address with a new one across multiple zones.

Topics

cdncloudflarecloudflare-apicloudflare-pycloudflare-pythoncloudflare-scriptdnsdns-migration-check-tooldns-migratorpypythonpython-cloudflarescript-cloudflare

Resources

Readme
MIT license
Activity

Stars

1 star

Watchers

1 watching

Forks

1 fork
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.