Sign inSign up

betterlmy/simple-cloudflare-ddns

By betterlmy

•Updated 7 months ago

A lightweight Cloudflare DDNS client implemented in Go!

Image
Networking
0

1.3K

betterlmy/simple-cloudflare-ddns repository overview

⁠Simple Cloudflare DDNS

A minimal Cloudflare Dynamic DNS client written in Go. No dependencies, single binary, configured entirely via environment variables.

How it works: Detect public IP → Compare with Cloudflare DNS record → Update only when changed

  • IPv4 (A) and IPv6 (AAAA) support
  • Auto-selects IP detection service based on record type (IPv4 or IPv6 endpoints of icanhazip / ifconfig.co / ipify)
  • Multi-arch: linux/amd64, linux/arm64
  • Runs as non-root user, Alpine-based (~20MB)

⁠Quick Start

⁠Docker run
docker run -d \
  --name cloudflare-ddns \
  --restart unless-stopped \
  -e CF_API_TOKEN=your-token \
  -e CF_ZONE_ID=your-zone-id \
  -e CF_RECORD_NAME=home.example.com \
  -e CF_RECORD_TYPE=A \
  betterlmy/simple-cloudflare-ddns:latest
⁠Docker Compose
services:
  cloudflare-ddns:
    image: betterlmy/simple-cloudflare-ddns:latest
    restart: unless-stopped
    environment:
      CF_API_TOKEN: your-token
      CF_ZONE_ID: your-zone-id
      CF_RECORD_NAME: home.example.com
      CF_RECORD_TYPE: A
      # CF_CHECK_INTERVAL: 300

⁠Environment Variables

VariableRequiredDescription
CF_API_TOKENYesCloudflare API token (DNS edit permission)
CF_ZONE_IDYesCloudflare Zone ID
CF_RECORD_NAMEYesDNS record to update, e.g. home.example.com
CF_RECORD_TYPEYesA (IPv4) or AAAA (IPv6)
CF_CHECK_INTERVALNoCheck interval in seconds (default: 300)
CF_TTLNoDNS TTL in seconds (default: inherits existing record)
CF_PROXIEDNotrue or false (default: inherits existing record)
CF_IP_URLSNoComma-separated IP detection service URLs (default: built-in list, auto-selected based on CF_RECORD_TYPE)

⁠How to Get Cloudflare Credentials

API Token

  1. Go to Cloudflare API Tokens⁠
  2. Create Token → "Edit zone DNS" template
  3. Set permissions: Zone:DNS:Edit, select your zone

Zone ID

  1. Go to Cloudflare Dashboard⁠
  2. Select your domain → find "Zone ID" in the bottom-right of the Overview page

⁠Notes

  • If your environment uses a proxy, add *.ipify.org, ifconfig.co, *.icanhazip.com to the bypass list.
  • For cron usage, run the binary with -once flag (not applicable in Docker daemon mode).

⁠Source

github.com/betterlmy/simple-cloudflare-ddns⁠

Tag summary

Content type

Image

Digest

sha256:76c54f8d9…

Size

9 MB

Last updated

7 months ago

docker pull betterlmy/simple-cloudflare-ddns