Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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.

License

NotificationsYou must be signed in to change notification settings

BaseMax/cloudflare-dns-ip-migrator-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.gitcd 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 iscloudflare_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 inexample.com andtest.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

FlagDescription
-o,--old-ip(Required) Old IP address to be replaced.
-n,--new-ip(Required) New IP address to set.
-r,--typeDNS record type (A,AAAA,CNAME,TXT). Default:A
-z,--zoneLimit to specific zone(s). Repeatable for multiple domains.
--dry-runPreview changes without making updates.
--verboseEnable detailed debug logging.
--jsonOutput 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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp