Skip to content

dfelix/cloudflare-ddns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Cloudflare DDNS

A lightweight Dynamic DNS updater for Cloudflare, running in a Docker container on Alpine Linux.

Automatically keeps your Cloudflare DNS A records pointing to your current public IP, and ensures a wildcard CNAME (*) exists for each zone.

How it works

  1. Fetches your public IP from api.ipify.org
  2. For each configured zone:
    • Looks up the Zone ID via the Cloudflare API
    • Creates or updates the root A record (@) if the IP has changed
    • Creates a wildcard CNAME record (* -> @) if it doesn't exist
  3. Sleeps for the configured interval, then repeats

The container handles SIGTERM/SIGINT for graceful shutdown and runs as a non-root user.

Environment variables

Variable Required Default Description
CF_TOKEN Yes Cloudflare API token with DNS edit permissions
ZONES Yes Comma-separated list of zones (e.g. example.com,example.org)
INTERVAL No 300 Seconds between update cycles
PROXIED No false Enable Cloudflare proxy (true or false)
TTL No 120 DNS record TTL in seconds

Usage

Docker run

docker run -d \
  --name cloudflare-ddns \
  --restart unless-stopped \
  -e CF_TOKEN="your-cloudflare-api-token" \
  -e ZONES="example.com,example.org" \
  -e INTERVAL=300 \
  -e PROXIED=false \
  dfelix/cloudflare-ddns

Docker Compose

services:
  cloudflare-ddns:
    image: dfelix/cloudflare-ddns
    container_name: cloudflare-ddns
    restart: unless-stopped
    environment:
      CF_TOKEN: "your-cloudflare-api-token"
      ZONES: "example.com,example.org"
      INTERVAL: 300
      PROXIED: false
      TTL: 120

Installation

Available on Docker Hub: dfelix/cloudflare-ddns

docker pull dfelix/cloudflare-ddns

Cloudflare API token

Create a token at Cloudflare Dashboard > API Tokens with:

  • Permissions: Zone > DNS > Edit
  • Zone Resources: Include > Specific zone (or All zones)

License

MIT

About

Wrote this just to update cloudflare dns for multiple domains from a single docker container, as most i've found required a container per each domain.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors