This week, I switched to a different telecommunications provider, which led to a dynamic public IP address. Consequently, in today’s blog post, I will discuss the implementation of CloudFlare DNS Service as a Dynamic DNS provider. This configuration ensures that services hosted on the home network remain accessible to remote users through a stable and automatically updated domain name.

cloudflare home ddns

Docker implementation

To avoid reinventing the wheel, I searched online to check if there was already a Docker-based service available for automatically updating Cloudflare’s A record with the current public IP. And I found it, I discovered a popular image that fulfills all my requirements: oznu/cloudflare-ddns
To run this service, I configured the docker-compose with the following settings:

docker-compose
1
2
3
4
5
6
7
8
9
10
11
12
13
version: '2'

services:
  cloudflare-ddns:
    image: oznu/cloudflare-ddns:latest
    restart: always
    container_name: cloudflare-ddns
    environment:
      - API_KEY=xxxxxxx
      - ZONE=example.com
      - SUBDOMAIN=subdomain
      - PROXIED=false
      - RRTYPE=A

This service every 5min (by default) checks the public IP and updates the DNS A record automatically.

Get Cloudflare API key

  1. From the Cloudflare dashboard, go to **My Profile ** > API Tokens.
  2. Select Create Token.
  3. Select the from the API token templates Edit zone DNS and press Use template. cloudflare template api key
  4. Select Continue to summary.
  5. Review the token summary. Select Edit token to make adjustments. You can also edit a token after creation.
  6. Select Create Token to generate the token’s secret.
  7. Copy the secret and use it as the environment variable API_KEY in the docker-compose.