Skip to content

fgiudici/ddflare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logo logo

example workflow example workflow

ddflare is a client to manage DNS type A records via the Cloudflare API.

It's primary usage is to provide a DDNS (Dynamic DNS) client leveraging the Cloudflare API.

Important

Since ddflare operates via the Cloudflare APIs, ddflare can update dns records for domains managed by Cloudflare only: this means your domain has been registered at or transfered to Cloudflare.

ddflare allows to:

  • retrieve the current public IP address
  • update domain names (FQDNs, recorded as type A records) to point to the current public address (or a custom IP)
  • resolve any domain name (acting as a DNS client)

Get ddflare

ddflare is released as statically compiled binaries for different OS/architetures that you can grab from the release page.

Get a x86_64 linux binary example:

wget https://github.com/fgiudici/ddflare/releases/download/v0.1.0/ddflare-linux-amd64
sudo install ddflare-linux-amd64 /usr/local/bin/ddflare

If you prefer a container image, you can pull ddflare from the github repository and run it via docker as usual:

docker run -ti --rm ghcr.io/fgiudici/ddflare

Usage

ddflare has two main commands: get, to retrieve the current public IP address (or resolve the FQDN passed as argument), and set, to update the type A record of the target FQDN to the current public ip (or a custom IP address).

Run ddflare help to display all the available commands and flags.

Update domain name to current public IP address (DDNS client)

Tip

In order to update domain names you need a Cloudflare API token with Zone.DNS Edit permission. You can create one following the Cloudflare docs.

To update a domain name (FQDN, type A record) to the current public IP address of the host run:

ddflare set -t <CLOUDFLARE_TOKEN> <FQDN>

where <FQDN> is the domain to be updated and <CLOUDFLARE_TOKEN> is a Cloudflare API token.

Real example with FQDN myhost.example.com and Cloudflare API token gB1fOLbl2d5XynhfIOJvzX8Y4rZnU5RLPW1hg7cM:

ddflare set -t gB1fOLbl2d5XynhfIOJvzX8Y4rZnU5RLPW1hg7cM  myhost.example.com

Note

ddflare can update existing A records but cannot create new ones, so the record should be created in advance.

To create an A record see Cloudflare's Manage DNS Records docs.

Tip

When creating a type A record pay attention to the value of the TTL field: it tracks the number of seconds DNS clients and DNS resolvers are allowed to cache the resolved IP address for the record. You may want to keep the TTL low (min is 60 secs) if you plan to use the record to track the (dynamic) IP address of a host in a DDNS scenario.

Get the current public IP address

Retrieving the current public IP address is as easy as:

ddflare get

ddflare queries the ipify.org service under the hood, which detects the public IP address used to reach the service.