A Simple Python based application that updates a Cloudflare DNS A record entry with a host's public IPv4 address.
The application polls Cloudflare's cdn-cgi/trace data every 15 minutes to
determine the host's public IPv4 address. On start up and on a change of the
hosts IPv4 address, the application will update Cloudflare DNS A record for
the provided domain.
Pre-built images are available via the GitHub Container Repository: ghcr.io/lucace/cloudflare-ddns
Copy and modify the docker-compose.yml file, setting the following environment variables:
| Variable | Type | Required | Default | Description |
|---|---|---|---|---|
| CLOUDFLARE_API_KEY | String | Yes | None | Cloudflare API Key |
| CLOUDFLARE_ZONE_ID | String | Yes | None | Cloudflare DNS Entry Zone ID |
| DOMAIN_NAME | String | Yes | None | Domain Name to Manage |
| VERBOSE | Boolean | No | False | Enable Verbose Messages |
| DOMAIN_TTL | Integer | No | 3600 | DNS Record Time to Live in Seconds |
| UPDATE_RATE | Integer | No | 900 | Polling Update Rate in Seconds |
Important
"{{ CLOUDFLARE_API_KEY }}", "{{ CLOUDFLARE_ZONE_ID }}", and "{{ DOMAIN NAME }}" in the
docker-compose.yml file example are placeholders and must be replaced with actual values.
services:
cloudflare-ddns:
container_name: cloudflare-ddns
image: ghcr.io/lucace/cloudflare-ddns:latest
environment:
VERBOSE: True
CLOUDFLARE_API_KEY: {{ CLOUDFLARE_API_KEY }}
CLOUDFLARE_ZONE_ID: {{ CLOUDFLARE_ZONE_ID }}
DOMAIN_NAME: {{ DOMAIN NAME }}
DOMAIN_TTL: 3600
UPDATE_RATE: 900
restart: unless-stopped
read_only: True
cap_drop: [all]
security_opt: [no-new-privileges:true]From the directory containing docker-compose.yml, start the container:
docker compose up -dThis application requires a Cloudflare API Key and a Zone ID to update the DNS entry for a domain.
A Cloudflare API Key with DNS editing permissions is required. The API key should only include the specific zone (doman name) that will be updated. Instructions on how to create an API Key can be found on Cloudflare's developer documentation site:
https://developers.cloudflare.com/fundamentals/api/get-started/create-token/
A Cloudflare Zone ID is a unique identifier Cloudflare assigns to each domain (called a zone) in your Cloudflare account. The Zone ID for the domain name record that will be updated is required and can be found in the Cloudflare web interface. Instructions on how to determine what the Zone ID is for a domain can be found on Cloudflare's developer documentation site:
https://developers.cloudflare.com/fundamentals/concepts/accounts-and-zones/
https://developers.cloudflare.com/fundamentals/account/find-account-and-zone-ids/