cf-ddns is a quick and basic Node.JS application which acts like a Dynamic DNS client for Cloudflare® DNS.
It fetches your machine's IPv4 address using ipify, and updates your Cloudflare DNS records specified using domains.json
. If the record doesn't exist, it will be created automatically.
cf-ddns was inspired by Scott Helme's CloudflareDDNS and performs similar functions, but does not require external hosting.
- Run
npm install
to install the dependencies (dotenv-safe
andaxios
) - Create a
.env
file based on.env.example
- Configure the
.env
anddomains.json
- Run
node index.js
- (Recommended) Use a process manager like
nodemon
orpm2
to keep cf-ddns running
A Cloudflare API token.
You can manage your API tokens from the Cloudflare dashboard.
cf-ddns requires 2 permissions: Read Zone.Zone, Edit Zone.DNS
The refresh interval for cf-ddns, in seconds.
Default is 30
.
Do take note of Cloudflare API rate limits when changing the value (1200 requests / 5 minutes).
A domain object consists of a name
string and subdomains
array of strings.
name
is the root domain as listed in Cloudflare DNS (e.g. example.com
)
subdomains
contains the subdomains that you wish to update the A DNS records of (e.g. blog.example.com
, or example.com
to update the root domain)
When using multiple subdomains, I suggest having only 1 A record pointing to the IPv4 address, then create aliases like CNAMEs pointing to that A record.
Cloudflare is a registered trademark of Cloudflare, Inc.