Skip to content

Warkstee/cloudflare-ddns-updater

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Cloudflare Dynamic DNS IP Updater (Multi-Record)

This script updates multiple Cloudflare DNS records with your current dynamic IP address. Access your home network remotely via a custom domain name without a static IP! Written in pure BASH.

Features

  • Multi-Record Support: Update multiple DNS records with a single script execution
  • Reliable IP Detection: Uses multiple services to fetch your public IP
  • Error Handling: Continues processing remaining records if one fails
  • Notification Support: Sends status updates to Slack and/or Discord

Installation

git clone https://github.com/Warkstee/cloudflare-ddns-updater.git

Configuration

  1. Copy the template file and fill in your Cloudflare credentials:
cp cloudflare-template.sh cloudflare-ddns-updater.sh
chmod +x cloudflare-ddns-updater.sh
nano cloudflare-ddns-updater.sh
  1. Set your Cloudflare credentials in the file:
auth_email="[email protected]"         # The email used to login to Cloudflare
auth_method="token"                         # "global" for Global API Key or "token" for Scoped API Token
auth_key="your-api-token"                   # Your API Token or Global API Key
zone_identifier="your-zone-id"              # Can be found in the Overview tab of your domain
  1. Configure the domain records you want to update:
record_names=(                              # Array of records you want to be synced
  "example.com"
  "www.example.com"
  "subdomain.example.com"
)

Usage

This script is designed to be used with crontab. Specify the frequency of execution through crontab.

# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12)
# │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday 7 is also Sunday on some systems)
# │ │ │ │ │ ┌───────────── command to issue                               
# │ │ │ │ │ │
# │ │ │ │ │ │
# * * * * * /bin/bash /path/to/cloudflare-ddns-updater.sh

For example, to check every 5 minutes:

*/5 * * * * /bin/bash /path/to/cloudflare-ddns-updater.sh

Viewing Logs

The script logs to your system's logger. You can view the logs using:

# View all system logs
sudo journalctl -e | grep "DDNS Updater"

# Or traditional log files
sudo cat /var/log/syslog | grep "DDNS Updater"

Notifications

The script supports sending notifications to Slack and Discord. To enable:

  1. For Slack, configure the slackchannel and slackuri variables
  2. For Discord, configure the discorduri variable

Tested Environments

  • macOS Mojave version 10.14.6 (x86_64)
  • AlmaLinux 9.3 (Linux kernel: 5.14.0 | x86_64)
  • Debian Bullseye 11 (Linux kernel: 6.1.28 | aarch64)
  • Proxmox VE 8.4.11 (Linux 6.8.12-13-pve)

Origin and Modifications

This script is a modified version of K0p1-Git's cloudflare-ddns-updater, enhanced to support updating multiple DNS records simultaneously. The original script was created with reference from Keld Norman's video.

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages