Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

cloudflare-ddns

> DevOps
Open source

Rust based dynamic DNS (DDNS) updater for Cloudflare

4.4K stars0 likes1 views
WebsiteGitHub

About

Rust based dynamic DNS (DDNS) updater for Cloudflare

Cloudflare DDNS

Access your home network remotely via a custom domain name without a static IP!

A feature-complete dynamic DNS client for Cloudflare, written in Rust. The smallest and most memory-efficient open-source Cloudflare DDNS Docker image available — ~1.1 MB image size and ~3.5 MB RAM at runtime, smaller and leaner than Go-based alternatives. Built as a fully static binary from scratch with zero runtime dependencies.

Configure everything with environment variables. Supports notifications, heartbeat monitoring, WAF list management, flexible scheduling, and more.

✨ Features

  • Multiple IP detection providers — Cloudflare Trace, Cloudflare DNS-over-HTTPS, ipify, local interface, custom URL, or static IPs
  • IPv4 and IPv6 — Full dual-stack support with independent provider configuration
  • Multiple domains and zones — Update any number of domains across multiple Cloudflare zones
  • Wildcard domains — Support for *.example.com records
  • Internationalized domain names — Full IDN/punycode support (e.g. münchen.de)
  • ️ WAF list management — Automatically update Cloudflare WAF IP lists
  • Notifications — Shoutrrr-compatible notifications (Discord, Slack, Telegram, Gotify, Pushover, Zulip, generic webhooks)
  • Heartbeat monitoring — Healthchecks.io and Uptime Kuma integration
  • ⏱️ Cron scheduling — Flexible update intervals via cron expressions
  • Dry-run mode — Preview changes without modifying DNS records
  • Graceful shutdown — Signal handling (SIGINT/SIGTERM) with optional DNS record cleanup
  • Record comments — Tag managed records with comments for identification
  • Managed record regex — Control which records the tool manages via regex matching
  • Pretty output with emoji — Configurable emoji and verbosity levels
  • Zero-log IP detection — Uses Cloudflare's cdn-cgi/trace by default
  • CGNAT-aware local detection — Filters out shared address space (100.64.0.0/10) and private ranges
  • Cloudflare IP rejection — Automatically rejects Cloudflare anycast IPs to prevent incorrect DNS updates
  • Outage-proof updates — Transient IP detection failures never delete or overwrite existing DNS records
  • Tiny static binary — ~1.1 MB Docker image built from scratch, zero runtime dependencies

Quick Start

bash
docker run -d \
  --name cloudflare-ddns \
  --restart unless-stopped \
  --network host \
  -e CLOUDFLARE_API_TOKEN=your-api-token \
  -e DOMAINS=example.com,www.example.com \
  timothyjmiller/cloudflare-ddns:latest

That's it. The container detects your public IP and updates the DNS records for your domains every 5 minutes.

⚠️ --network host is required to detect IPv6 addresses. If you only need IPv4, you can omit it and set IP6_PROVIDER=none.

Authentication

Variable Description
CLOUDFLARE_API_TOKEN API token with "Edit DNS" capability
CLOUDFLARE_API_TOKEN_FILE Path to a file containing the API token (Docker secrets compatible)

To generate an API token, go to your Cloudflare Profile and create a token capable of Edit DNS.

Domains

Variable Description
DOMAINS Comma-separated list of domains to update for both IPv4 and IPv6
IP4_DOMAINS Comma-separated list of IPv4-only domains
IP6_DOMAINS Comma-separated list of IPv6-only domains

Wildcard domains are supported: *.example.com

At least one of DOMAINS, IP4_DOMAINS, IP6_DOMAINS, or WAF_LISTS must be set.

IP Detection Providers

Variable Default Description
IP4_PROVIDER ipify IPv4 detection method
IP6_PROVIDER cloudflare.trace IPv6 detection method

Available providers:

Provider Description
cloudflare.trace Cloudflare's /cdn-cgi/trace endpoint (default, zero-log)
cloudflare.doh Cloudflare DNS-over-HTTPS (whoami.cloudflare TXT query)
ipify ipify.org API
local Local IP via system routing table (no network traffic, CGNAT-aware)
local.iface:<name> IP from a specific network interface (e.g., local.iface:eth0)
local.iface.stable:<name> Preferred stable IPv6 address from a Linux network interface, excluding temporary/deprecated addresses
url:<url> Custom HTTP(S) endpoint that returns an IP address
literal:<ips> Static IP addresses (comma-separated)
none Disable this IP type

Cloudflare IP Rejection

Variable Default Description
REJECT_CLOUDFLARE_IPS true Reject detected IPs that fall within Cloudflare's IP ranges

Some IP detection providers occasionally return a Cloudflare anycast IP instead of your real public IP. When this happens, your DNS record gets updated to point at Cloudflare infrastructure rather than your actual address.

By default, each update cycle fetches Cloudflare's published IP ranges and skips any detected IP that falls within them. A warning is logged for every rejected IP. If the ranges cannot be fetched, the update is skipped entirely to prevent writing a Cloudflare IP.

To disable this protection, set REJECT_CLOUDFLARE_IPS=false.

⏱️ Scheduling

Variable Default Description
UPDATE_CRON @every 5m Update schedule
UPDATE_ON_START true Run an update immediately on startup
DELETE_ON_STOP false Delete managed DNS records on shutdown
DELETE_ON_FAILURE false Delete managed DNS records when a provider definitively reports no address of that family (see below)

Schedule formats:

  • @every 5m — Every 5 minutes
  • @every 1h — Every hour
  • @every 30s — Every 30 seconds
  • @once — Run once and exit

When UPDATE_CRON=@once, UPDATE_ON_START must be true and DELETE_ON_STOP must be false.

Detection Failure Behavior

A failed IP detection never breaks your DNS. Two cases are distinguished:

  • Transient failure — a network-based provider (cloudflare.trace, cloudflare.doh, ipify, url:) errored, or all detected IPs were rejected as Cloudflare IPs. The real IP is unknown, so the update is skipped and existing DNS records and WAF list items are always preserved, regardless of DELETE_ON_FAILURE. If detection fails for one address family, WAF list updates are skipped entirely so the failed family's IPs aren't stripped from the list.
  • Definitive absence — a deterministic provider (none, literal:, local, local.iface:) reports that the host has no address of that family. With DELETE_ON_FAILURE=true the managed records for that family are deleted; with the default false the update is skipped and existing records are preserved.

DNS Record Settings

Variable Default Description
TTL 1 (auto) DNS record TTL in seconds (1=auto, or 30-86400)
PROXIED false Expression controlling which domains are proxied through Cloudflare
RECORD_COMMENT (empty) Comment attached to managed DNS records
MANAGED_RECORDS_COMMENT_REGEX (empty) Regex to identify which records are managed (empty = all)

The PROXIED variable supports boolean expressions:

Expression Meaning
true ☁️ Proxy all domains
false Don't proxy any domains
is(example.com) Only proxy example.com
sub(cdn.example.com) Proxy cdn.example.com and its subdomains
is(a.com) || is(b.com) Proxy a.com or b.com
!is(vpn.example.com) Proxy everything except vpn.example.com

Operators: is(), sub(), !, &&, ||, ()

️ WAF Lists

Variable Default Description
WAF_LISTS (empty) Comma-separated WAF lists in account-id/list-name format
WAF_LIST_DESCRIPTION (empty) Description for managed WAF lists
WAF_LIST_ITEM_COMMENT (empty) Comment for WAF list items
MANAGED_WAF_LIST_ITEMS_COMMENT_REGEX (empty) Regex to identify managed WAF list items

WAF list names must match the pattern [a-z0-9_]+.

Notifications (Shoutrrr)

Variable Description
SHOUTRRR Newline-separated list of notification service URLs

Supported services:

Service URL format
Discord discord://token@webhook-id
Slack slack://token-a/token-b/token-c
✈️ Telegram telegram://bot-token@telegram?chats=chat-id
Gotify gotify://host/path?token=app-token
Pushover pushover://user-key@api-token
Zulip zulip://bot-mail:bot-key@host/?stream=stream-name&topic=topic-name
Generic webhook generic://host/path or generic+https://host/path

For Zulip, the @ in the bot email may be written literally or percent-encoded (%40), and topic is optional (defaults to Cloudflare DDNS).

Generic webhooks send a JSON payload of {"message": "..."}. Use ?messagekey=<field> to rename the field, e.g. generic://host/path?messagekey=text for services expecting Slack-style payloads.

Notifications are sent when DNS records are updated, created, deleted, or when errors occur.

Heartbeat Monitoring

Variable Description
HEALTHCHECKS Healthchecks.io ping URL
UPTIMEKUMA Uptime Kuma push URL

Heartbeats are sent after each update cycle. On failure, a fail signal is sent. On shutdown, an exit signal is sent.

⏳ Timeouts

Variable Default Description
DETECTION_TIMEOUT 5s Timeout for IP detection requests
UPDATE_TIMEOUT 30s Timeout for Cloudflare API requests

️ Output

Variable Default Description
EMOJI true Use emoji in output messages
QUIET false Suppress informational output

CLI Flags

Flag Description
--dry-run Preview changes without modifying DNS records
--repeat Run continuously (legacy config mode only; env var mode uses UPDATE_CRON)

All Environment Variables

Variable Default Description
CLOUDFLARE_API_TOKEN — API token
CLOUDFLARE_API_TOKEN_FILE — Path to API token file
DOMAINS — Domains for both IPv4 and IPv6
IP4_DOMAINS — 4️⃣ IPv4-only domains
IP6_DOMAINS — 6️⃣ IPv6-only domains
IP4_PROVIDER ipify IPv4 detection provider
IP6_PROVIDER cloudflare.trace IPv6 detection provider
UPDATE_CRON @every 5m ⏱️ Update schedule
UPDATE_ON_START true Update on startup
DELETE_ON_STOP false Delete records on shutdown
DELETE_ON_FAILURE false Delete records when provider definitively reports no IP
TTL 1 ⏳ DNS record TTL
PROXIED false ☁️ Proxied expression
RECORD_COMMENT — DNS record comment
MANAGED_RECORDS_COMMENT_REGEX — Managed records regex
WAF_LISTS — ️ WAF lists to manage
WAF_LIST_DESCRIPTION — WAF list description
WAF_LIST_ITEM_COMMENT — WAF list item comment
MANAGED_WAF_LIST_ITEMS_COMMENT_REGEX — Managed WAF items regex
DETECTION_TIMEOUT 5s ⏳ IP detection timeout
UPDATE_TIMEOUT 30s ⏳ API request timeout
REJECT_CLOUDFLARE_IPS true Reject Cl

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rustamd64arm64armv7cloudflare-ddns

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
CategoryDevOps
PricingOpen source

> Related tools

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理