A small synchronous client that updates Cloudflare DNS records with the current
public IP address. It supports IPv4 (A) and IPv6 (AAAA) records.
The program performs one update pass and exits. Use cron, a systemd timer or another scheduler to choose how often it runs.
On Debian-based Linux distributions (amd64 and arm64):
curl -L https://raw.githubusercontent.com/magonxesp/cloudflare-ddns/refs/heads/main/scripts/install.sh |
sudo bash -The installer downloads the package for the current architecture from the
latest GitHub release
and installs it with dpkg.
Copy the example configuration:
mkdir -p ~/.config/cloudflare-ddns
curl -L \
https://raw.githubusercontent.com/magonxesp/cloudflare-ddns/refs/heads/main/example-config.yaml \
-o ~/.config/cloudflare-ddns/config.yamlThe configuration is discovered in this order:
--config <FILE>~/.cloudflare-ddns/config.yaml$XDG_CONFIG_HOME/cloudflare-ddns/config.yaml, or~/.config/cloudflare-ddns/config.yaml/etc/cloudflare-ddns/config.yaml
Set the API token in config.yaml:
cloudflare:
api_token: your-cloudflare-api-tokenThe token needs DNS edit permission for the configured zones. A complete
annotated configuration is available in
example-config.yaml.
Because the configuration contains a credential, restrict its permissions:
chmod 600 ~/.config/cloudflare-ddns/config.yamlRun one update pass:
cloudflare-ddnsInspect changes without writing to Cloudflare:
cloudflare-ddns --dry-runUse a specific configuration:
cloudflare-ddns --config /path/to/config.yamlFor example, this cron entry runs the client every five minutes:
*/5 * * * * /usr/bin/cloudflare-ddnsdocker pull magonx/cloudflare-ddns:latest
docker run --rm \
-v "$PWD/config.yaml:/etc/cloudflare-ddns/config.yaml:ro" \
magonx/cloudflare-ddns:latestRust 1.85 or newer is required because the project uses the Rust 2024 edition.
cargo build --release
cargo testThe release executable is written to target/release/cloudflare-ddns.
On a Debian-based system with dpkg-deb installed:
make debThe package is written to:
target/release/bundle/cloudflare-ddns_<version>_<architecture>.deb
Install it with:
sudo apt install ./target/release/bundle/cloudflare-ddns_*.debThe executable is installed in /usr/bin/cloudflare-ddns. An annotated
configuration is installed in /usr/share/cloudflare-ddns/config.yaml as a
reference; copy it to /etc/cloudflare-ddns/config.yaml before editing it.
The services in docker-compose.yml allow the Linux build, Debian package and
application container to be tested from macOS or another system with Docker
Compose installed.
Prepare the home directory shared by the containers:
make sandboxThis creates sandbox/home/.config/cloudflare-ddns/config.yaml from the example
configuration. Edit that copy with the zones and records used for testing.
Build the Debian package with the packager service:
docker compose run --rm packagerThe resulting package is written to target/release/bundle, just like a local
make deb invocation. Its architecture matches the container architecture.
Install the package in a disposable Debian container and verify the executable:
docker compose run --rm sandbox bash -lc \
'dpkg --install target/release/bundle/cloudflare-ddns_*.deb && cloudflare-ddns --help'To test the application image itself, put the token in the sandbox
config.yaml and perform a dry run:
docker compose run --rm \
cloudflare_ddns \
--dry-run