Dynamic DNS
Dynamically update DNS when a static IP is not present.
For home server hosting, it is common that providers allocate dynamic IP addresses. This can be frustrating because when an IP address changes, the domain it's tied with becomes unusable.
Below is a docker compose file which runs a frequent check of system's IP address. If any changes are discovered it will push the new address to cloudflare.
Cloudflare API
To get your API token, visit Cloudflare, go to My Profile, select API tokens and then choose Create Token.
Use the template Edit zone DNS.
Change to the following settings, click Continue to Summary and then Create Token.
- Zone - Zone Settings - Read
- Zone - Zone - Read
- Zone - DNS - Edit
- Zone Resources - Include - All Zones
Docker compose
The following must be pasted into a file called docker-compose.yml, with changes to CLOUDFLARE_API_KEY and DOMAIN.COM.
version: "3"
services:
# Update dynamic IP to CF
cloudflare-ddns:
image: oznu/cloudflare-ddns:latest
container_name: cf-ddns
network_mode: bridge
restart: always
environment:
- API_KEY=CLOUDFLARE_API_KEY
- ZONE=DOMAIN.COM
- PROXIED=trueOnce this is done, the container can be started by running:
docker compose up -d