Skip to content

Dynamic DNS using Cloudflare. Emute a static IP with an auto-updating DNS record.

License

Notifications You must be signed in to change notification settings

lobis/cloudflare-ddns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

cloudflare-ddns

Dynamic DNS using Cloudflare's API.

This repository contains a bash script that updates a Cloudflare DNS record with the public IP of the machine it's running on.

In order to use this script, you need to have a Cloudflare account and a domain with Cloudflare nameservers.

Requirements

  • curl: The script uses curl to make requests to the Cloudflare API.
  • grep: The script uses grep to parse the response from the Cloudflare API. This is a standard Unix utility and should be available on most systems.
  • awk: The script uses awk to parse the response from the Cloudflare API. This is a standard Unix utility and should be available on most systems.

Usage

The script takes three positional arguments:

  1. CF_API_TOKEN: Your Cloudflare API token.
  2. CF_ZONE_ID: The ID of the zone containing the DNS record you want to update (available in the Cloudflare dashboard).
  3. DNS_RECORD_NAME: The name of the DNS A record you want to update as a fully qualified domain name (e.g. record.example.com). You need to have this record already created in your Cloudflare account.
bash ./cloudflare-update-dns-record.sh $CF_API_TOKEN $CF_ZONE_ID $DNS_RECORD_NAME

It is recommended to make the script executable and add it to your crontab to run it periodically.

First place the script in an appropriate location, for example /usr/local/bin/cloudflare-update-dns-record.sh.

# Download the script to /usr/local/bin
curl -o /usr/local/bin/cloudflare-update-dns-record.sh https://raw.githubusercontent.com/lobis/cloudflare-ddns/main/cloudflare-update-dns-record.sh
# Make the script executable
chmod +x /usr/local/bin/cloudflare-update-dns-record.sh

Then open your crontab:

crontab -e

Add the following line to run the script every 5 minutes (replace the placeholders with your actual values):

*/5 * * * * /usr/local/bin/cloudflare-update-dns-record.sh $CF_API_TOKEN $CF_ZONE_ID $DNS_RECORD_NAME

About

Dynamic DNS using Cloudflare. Emute a static IP with an auto-updating DNS record.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages