Skip to main content

This script updates a dns record in your Cloudflare account to match your current public IP address.
First it checks your IP address, and if it is different from the IP address in your Cloudflare dns record, it updates the dns record in Cloudflare.
It will run automatically at preset intervals.

Prerequisites

To run this script you need a Cloudflare User API Token
with the following Permissions:
Zone - Zone - Read
Zone - DNS - Edit
and the following Zone Resources:
Include - Specific zone - yourdomain.xxx

These permissions are necessary to check the names and IDs of your dns records (Zone Read)
and to change the IP address of a particular record (DNS Edit).

During setup, the script checks if crontab is installed and accessible.
If not, it will exit. In this case you should setup crontab or run the script as root.
In Debian 12 all users have crontab available
In Alpine linux the user needs to run crontab -e, and write a comment line to enable crontab.

How to obtain a Cloudflare API Token

Login to Cloudflare
Click on My Profile (top right)
Click on API Tokens
Click on the 'Create Token' button
Click on the 'Use template' button of Edit zone DNS
Modify Permissions so that you have the following settings:
Zone - Zone - Read
Zone - DNS - Edit
and the following Zone Resources:
Include - Specific zone - yourdomain.xxx
Click on the 'Continue to summary' button
Click on the 'Create Token' button.
Save the Token

Security

The Cloudflare token input is not visible on most terminals (similar to Linux password) and is saved in a json file readable only by the user (and root).

Installation

To install on recent Linux systems use pipx.
On older systems you can use pip.

On Debian or Ubuntu

  • apt install pipx

On Alpine Linux

  • apk add pipx

Once installed:

  • pipx ensurepath
  • Logout and login again (or reboot)
  • pipx install cloudflare-ddns-updater

Setup

To setup the program

  • cloudflare-ddns-updater --setup

To change IP check interval

  • cloudflare-ddns-updater --cron

To stop automatic ip update

  • cloudflare-ddns-updater --stop

To resume automatic IP update

  • cloudflare-ddns-updater --start

To change log level

  • cloudflare-ddns-updater --logs

To remove all files created by the script

  • cloudflare-ddns-updater --cleanup

To check the logs

  • follow the log file path shown after installation

To uninstall

  • cloudflare-ddns-updater --cleanup
  • pipx uninstall cloudflare-ddns-updater

Changes:
1.0.5 - Added date-time to Cloudflare record comment
Added log file path when --log option is used
1.0.4 - Fixed bug that would try to change the TXT or MX record\ if trying to change the root domain (mydomain.xxx)
1.0.3 - Removed dns proxy from cloudflare and forced ttl to 120 seconds
1.0.2 - Added github repository
1.0.1 - Added log entries for cron changes
1.0.0 - First official release

Release files for cloudflare-ddns-updater 1.0.5

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-ddns-updater 1.0.5
File Size Uploaded
cloudflare_ddns_updater-1.0.5.tar.gz 11.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for cloudflare-ddns-updater 1.0.5
File Interpreter ABI Platform
cloudflare_ddns_updater-1.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 23.8 kB

Release files / cloudflare_ddns_updater-1.0.5.tar.gz

Download URL cloudflare_ddns_updater-1.0.5.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8ff22e86e975c288a724b3d5cdd42b346b99525b74d8161a2943539fcc9feb77
BLAKE2b-256 checksum
How to use checksums
f56ab4af199cfeed8dfdad4e5abc667ceb68e211fc84233585d40a14e8b4fb97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.1

Release files / cloudflare_ddns_updater-1.0.5-py3-none-any.whl

Download URL cloudflare_ddns_updater-1.0.5-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3251f9490ebc8e647b58674d23bdfc3d9ed0f40ef694b82ead2a52cbafdc595c
BLAKE2b-256 checksum
How to use checksums
aab40f78f959d9fb906abd3eacb80a2f874fcfa0914c3011aec0103fdbe3dd48
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.1

Release history Release notifications | RSS feed

This release

1.0.5 This release

2 release files

1.0.4

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

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