#cloudflare #ddns #cli #cli-tool #dns-records

app cloudflare-ddns

A simple CLI tool to use Cloudflare's free DDNS service

5 unstable releases

0.3.0 Apr 21, 2020
0.2.1 Mar 22, 2020
0.2.0 Sep 23, 2019
0.1.8 Sep 21, 2019
0.1.6 Sep 18, 2019

#12 in #ddns

42 downloads per month

MIT license

251 lines

CloudFlare DDNS update tool

This is a simple CLI you can use to continuously update an A DNS record for a domain using CloudFlare's free DDNS service.


    -t, --token <api-token>     The API token you need to generate in your Cloudflare profile
    -c, --cache <cache>      Cache file for previously reported IP address (if skipped the IP will be reported on every
    -f, --config <config>    Your TOML config file containing all the required options (email, auth_key, zone, domain)
                             which you can use instead of passing the arguments to the command line
    -d, --domain <domain>    The domain for which you want to report the current IP address
    -z, --zone <zone>        The zone in which your domain is (usually that is your base domain name)


You Can pass a path to a configuration file (-f or --config) instead of each option as a command line argument. The configuration should be a TOML file and hold the same options. Here's a sample:

api_token = "secretkey"
domain = "example.example.com"
zone = "example.com"

Cloudflare Setup

You need to do some preparatory work in Cloudflare. Firstly this assumes you're using Cloudflare already to manage the DNS records for your domain.

Initial DNS setup

You need to add a type A DNS record for your domain. The Name field you should fill in with the name of the subdomain. If you don't want to use a subdomain just type @ then the base domain will be used. Then change the Proxy status field to be not Proxied but DNS only. This will allow you to input in the IPv4 Address field. Then click the save button. You might need to wait sometime before the DNS record propagates.

API token

We need to authenticate ourselves in front of the Cloudflare API. To do so we need to an API token to pass along with every request. You can generate an API token to use specifically with this application on Cloudflare in My profile > API Tokens > Create Token.


~407K SLoC