Skip to main content

CloudFlare Dynamic DNS client

This is a simple Dynamic DNS script written in Python for updating CloudFlare DNS A records,
similar to the classic ddclient perl script.

  • You can run it as a cron job or a systemd timer.
  • It only updates the records if the IP address actually changed by storing a cache of the current IP address.
  • It checks multiple IP services. If one of them doesn't respond, it skips it and check the next.
  • It has an easy to use command line interface.

Install

The simplest way to run this script is using the uv Python package manager:

$ uvx cloudflare-dyndns

You can install it with pip from PyPI:

$ pip install cloudflare-dyndns

There is a Nix package available as well:

nix-shell -p cloudflare-dyndns

Or you can even configure NixOS to use it as a service by setting services.cloudflare-dyndns options in configuration.nix.
See man 5 configuration.nix on NixOS for details.

You can use the Docker image:

$ docker run --rm -it kissgyorgy/cloudflare-dyndns --help

Please note that before you can use the -6 IPv6 option in Docker, you need to enable IPv6 support in the Docker daemon. Afterward, you can choose to use either IPv4 or IPv6 (or both) with any container, service, or network.

Note

If you use this script, it "takes over" the handling of the record of those domains you specified, which means it will update existing records and create missing ones.

You should not change A or AAAA records manually or with other scripts, because the changes will be overwritten.

I decided to make it work this way, because I think most users expect this behavior, but if you have a different use case, let me know!

Command line interface

$ cloudflare-dyndns --help
Usage: cloudflare-dyndns [OPTIONS] [DOMAINS]...

  A command line script to update CloudFlare DNS A and/or AAAA records based
  on the current IP address(es) of the machine running the script.

  For the main domain (the "@" record), simply put "example.com".
  Subdomains can also be specified, eg. "*.example.com" or "sub.example.com"

  You can set the list of domains to update in the CLOUDFLARE_DOMAINS
  environment variable, in which the domains has to be separated by
  whitespace, so don't forget to quote the value!

  The script supports both IPv4 and IPv6 addresses. The default is to set only
  A records for IPv4, which you can change with the relevant options.

Options:
  --api-token TEXT       CloudFlare API Token (You can create one at My
                         Profile page / API Tokens tab). Can be set with
                         CLOUDFLARE_API_TOKEN environment variable. Mutually
                         exclusive with `--api-token-file`.
  --api-token-file FILE  File containing CloudFlare API Token (You can create
                         one at My Profile page / API Tokens tab). Can be set
                         with CLOUDFLARE_API_TOKEN_FILE environment variable.
                         Mutually exclusive with `--api-token`.
  --verify-token         Check if the API token is valid through the
                         CloudFlare API.
  --proxied              Whether the records are receiving the performance and
                         security benefits of Cloudflare.
  -4 / -no-4             Turn on/off IPv4 detection and set A records.
                         [default: on]
  -6 / -no-6             Turn on/off IPv6 detection and set AAAA records.
                         [default: off]
  --delete-missing       Delete DNS record when no IP address found. Delete A
                         record when IPv4 is missing, AAAA record when IPv6 is
                         missing.
  --cache-file FILE      Cache file  [default: (~/.cache/cloudflare-
                         dyndns/ip.cache)]
  --force                Delete cache and update every domain
  --debug                More verbose messages and Exception tracebacks
  --version              Show the version and exit.
  --help                 Show this message and exit.

Shell exit codes

  • 1: Unknown error happened
  • 2: IP cannot be determined (IP service error)
  • 3: CloudFlare related error (cannot call API, cannot get records, etc...)

Changelog

See the Releases page for a full Changelog.

Development

The development is done with devenv (https://devenv.sh), you don't need anything else, just install devenv and run devenv shell and you are good to go.

Run uv sync to install dependencies or pytest to run the tests.

Release files for cloudflare-dyndns 5.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cloudflare-dyndns 5.4
File Size Uploaded
cloudflare_dyndns-5.4.tar.gz 25.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cloudflare-dyndns 5.4
File Interpreter ABI Platform
cloudflare_dyndns-5.4-py3-none-any.whl Python 3 none any Details

Total release size: 38.2 kB

Release files / cloudflare_dyndns-5.4.tar.gz

Download URL cloudflare_dyndns-5.4.tar.gz
Size 25.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7cb68845b19f6683f984f71f5608bb142026765bae16e9c0386aeba626f6bb3b
BLAKE2b-256 checksum
How to use checksums
249bd77d8eb623025041388466a0e02dfe271aca081daa54b137528f2d61c64e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.17

Release files / cloudflare_dyndns-5.4-py3-none-any.whl

Download URL cloudflare_dyndns-5.4-py3-none-any.whl
Size 12.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
da1f05ddef4b62a734b3a5c034482a7c47c9b30ab38ed0e90a4b2c2fe4ab1b5d
BLAKE2b-256 checksum
How to use checksums
628ff50f3db6bb72916f3c20a246e4bad31b0fbb131f815dc6c6c1e90cf61caf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.17

Release history Release notifications | RSS feed

This release

5.4 This release

2 release files

5.3

2 release files

5.2

2 release files

5.1

2 release files

5.0

2 release files

4.1

2 release files

4.0

2 release files

3.0

2 release files

2.1

2 release files

2.0

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page