/cloudflare-ddns

GNU General Public License v3.0GPL-3.0

CloudFlare DDNS

This small script that will allow you to use the free CloudFlare DNS Service as a Dynamic DNS Provider (DDNS).

Setup

Config File (ddns.conf)

  • CF_API=https://api.cloudflare.com/client/v4 - CloudFlare API URL. Required
  • API_KEY - Your CloudFlare scoped API token. See the Creating a Cloudflare API token below. Required
  • RRTYPE - Set to AAAA to use set IPv6 records instead of A for IPv4 records. Required
  • ZONE - The DNS zone that DDNS updates should be applied to. Required
  • SUBDOMAIN - A subdomain of the ZONE to write DNS changes to. If this is not supplied the root zone will be used.
  • PROXIED - Set to true to make traffic go through the CloudFlare CDN. Defaults to false.
  • CUSTOM_LOOKUP_CMD="echo '1.1.1.1'" - Set to any shell command to run them and have the IP pulled from the standard output. Leave unset to use default IP address detection methods.

Creating a Cloudflare API token

To create a CloudFlare API token for your DNS zone go to https://dash.cloudflare.com/profile/api-tokens and follow these steps:

  1. Click Create Token
  2. Provide the token a name, for example, cloudflare-ddns
  3. Grant the token the following permissions:
    • Zone - Zone Settings - Read
    • Zone - Zone - Read
    • Zone - DNS - Edit
  4. Set the zone resources to:
    • Include - All zones
  5. Complete the wizard and copy the generated token into the API_KEY variable for the container

Multiple Domains

If you need multiple records pointing to your public IP address you can create CNAME records in CloudFlare.

IPv6

If you're wanting to set IPv6 records set the envrionment variable RRTYPE=AAAA. You will also need to run docker with IPv6 support, or run the container with host networking enabled.

License

Copyright (C) 2021

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.