Skip to content

edward-ji/cf-ddns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Cloudflare DDNS

This repository provides a lightweight Dynamic DNS (DDNS) client for Cloudflare using a shell script and systemd timer. It checks your public IP periodically and updates your Cloudflare DNS A record if your IP changes.

Features

  • Automatically detects your public IP
  • Updates your DNS A record via Cloudflare API
  • Skips update if IP hasn't changed
  • Logs activity via systemd journal (journalctl -t cf-ddns)
  • Fully automated installation with a single script

Prerequisites

  • A domain managed in Cloudflare
  • Zone ID of the domain
  • A DNS record (type A) already created
  • A Cloudflare API Token with Zone DNS Edit permissions
  • jq, curl, and systemd

Installation

Clone the repo and run:

sudo ./install

Alternatively, without cloning:

curl -fsSL https://raw.githubusercontent.com/Edward-Ji/cf-ddns/main/install | sudo bash

The script will:

  1. Prompt for your Zone ID, API token, and DNS record name
  2. Validate your API token via the /user/tokens/verify endpoint
  3. Automatically fetch the DNS Record ID
  4. Prompt for TTL, proxying, IP query domain, and update interval
  5. Save credentials and config to /etc/cf-ddns/env
  6. Install the cf-ddns script and set up a systemd service + timer

To view logs:

journalctl -t cf-ddns

Configuration

All configuration values are stored in:

/etc/cf-ddns/env

This file is sourced by the systemd service. To update any value:

sudo nano /etc/cf-ddns/env
sudo systemctl restart cf-ddns.timer

Uninstallation

To fully remove cf-ddns, run:

sudo ./uninstall

Or if not cloned:

curl -fsSL https://raw.githubusercontent.com/Edward-Ji/cf-ddns/main/uninstall | sudo bash

This will:

  • Stop and disable the timer
  • Remove the systemd unit files
  • Delete the updater script, environment file, and saved IP state

About

Dynamic DNS service using Cloudflare

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages