No description
  • Shell 95.7%
  • Dockerfile 4.3%
Find a file
2025-07-13 12:05:39 +02:00
.github/workflows Removed Debian buster from CI build images 2025-07-13 12:05:39 +02:00
.vscode Corrected image names in VSCode-Tasks 2022-02-16 02:45:12 +01:00
.gitignore Updated .gitignore 2025-03-11 23:13:12 +01:00
cf_ddns.sh Update cf_ddns.sh 2025-06-27 01:37:18 +02:00
Dockerfile Update Dockerfile 2025-06-27 01:35:37 +02:00
README.md Update README.md 2025-06-27 01:42:09 +02:00
renovate.json Migrate config renovate.json 2025-03-11 23:01:13 +00:00

Cloudflare DDNS (DynDNS)

This is a simple script that dynamically can update a chosen (sub-)domain with your current IPv4 (Type A) and/or IPv6 (Type AAAA).

Each run, this script checks for your current IPv4 & IPv6, compares them to a cache and only updates your CloudFlare entries if a mismatch is found. You can freely choose which (sub-)domains are being run.

Warning

Please use this script with proper care.
I do not endorse spamming CloudFlare or ICanHazIP.com! Running this script every 15-30m should be more than enough, if you need quicker updates consider changing the IP provider, ICanHazIP.com, to a service of your own or replace it with a locally known public IP address.

Setup

To get started you only need to download the cf_ddns.sh script and run it.
A settings file should be generated with instructions. Change the settings file to your needs and rerun the script.

Once the script ran at least once with proper settings, two more files should be created:

  • ipv4.last: A local cache of your last IPv4 address
  • ipv6.last: A local cache of your last IPv6 address

Do not remove those files! These store your last IP and are used to compare your current IP's against your last ones. This is done to prevent even more API calls to CloudFlare.
However, this does not track changes done by other tools!

If you need to force an update, simply call the script with --force.

This script is intended to be run regularly as a one-shot script.
You may wanna setup a local Cron task to run this script e.g. every 30m.

Docker

If you want to run this script inside Docker, you can use a ready made container!
Make sure to read through the Setup section first and create your setting file as it will be needed to run the Docker container!

docker run -it \
    --rm \
    --mount type=bind,source="$(pwd)"/ipv4.last,target=/opt/cf_ddns/ipv4.last \
    --mount type=bind,source="$(pwd)"/ipv6.last,target=/opt/cf_ddns/ipv6.last \
    --mount type=bind,source="$(pwd)"/settings,target=/opt/cf_ddns/settings \
    ghcr.io/sakulflee/cloudflare-ddns:latest

Note

This is still a one-shot script!
The container will execute the script, then exit and destroy itself (if --rm is used).

You will still need to use something like Cron to schedule this container to be run.

Alternatively, you could create the container once and simply rerun it every time:

docker create -it \
    --name cf_ddns \
    --mount type=bind,source="$(pwd)"/ipv4.last,target=/opt/cf_ddns/ipv4.last \
    --mount type=bind,source="$(pwd)"/ipv6.last,target=/opt/cf_ddns/ipv6.last \
    --mount type=bind,source="$(pwd)"/settings,target=/opt/cf_ddns/settings \
    ghcr.io/sakulflee/cloudflare-ddns:latest

And every iteration simply call:

docker start cf_ddns

Note

This is still a one-shot script!
The only difference is that there now is a container lingering around waiting to be started.

You will still need to use something like Cron to schedule this container to be run.