From 129af44d57375b8eb20ebe6c74b22a71dee46bbe Mon Sep 17 00:00:00 2001 From: Jared Komoroski Date: Thu, 24 Dec 2020 15:25:22 -0700 Subject: [PATCH] Add Cloudflare DDNS (#80) --- README.md | 5 ++ cloudflare-ddns/README.md | 46 +++++++++++++++++++ cloudflare-ddns/configs/config.json | 20 ++++++++ .../on_boot.d/30-cloudflare-ddns.sh | 15 ++++++ 4 files changed, 86 insertions(+) create mode 100644 cloudflare-ddns/README.md create mode 100644 cloudflare-ddns/configs/config.json create mode 100644 cloudflare-ddns/on_boot.d/30-cloudflare-ddns.sh diff --git a/README.md b/README.md index 65ce0bf..f2a56c3 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,10 @@ Run NextDNS on your UDM with podman. Run AdguardHome on your UDM with podman. +### Cloudflare DDNS + +Update your cloudflare domains from your UDM with podman. + ## Cool projects you can use with this ### multicast-relay @@ -65,3 +69,4 @@ Provision and renew LetsEncrypt SSL certs from your UDM/P ### OpenConnect VPN OpenConnect VPN Client for the UniFi Dream Machine Pro (Unofficial) + diff --git a/cloudflare-ddns/README.md b/cloudflare-ddns/README.md new file mode 100644 index 0000000..c58cdb6 --- /dev/null +++ b/cloudflare-ddns/README.md @@ -0,0 +1,46 @@ +# Cloudflare Dynamic DNS + +## Features + +- Update Multiple Subdomains +- Proxy your traffic through cloudflare +- Set a ttl + +Complete feature list and documentation can be found [here](https://github.com/timothymiller/cloudflare-ddns) + + +## Requirements + +1. You have successfully setup the on boot script described [here](https://github.com/boostchicken/udm-utilities/tree/master/on-boot-script) +2. You must have a cloudflare profile with at least one domain. +3. You must have a valid cloudflare api token with correct permissions (see [complete documentation](https://github.com/timothymiller/cloudflare-ddns) for details) + +## Customization + +Update [config.json](configs/config.json) with the following options: +- your cloudflare api token +- your zone id +- each subdomain you'd like to point at your udm-pro +- Set the proxied flag if you'd like cloudflare to proxy the records +- Set the ttl value you'd like for your records + +## Steps + +2. Make a directory for your configuration + + ```sh + mkdir -p /mnt/data/cloudflare-ddns + ``` + +3. Create a [cloudflare-ddns configuration](configs/config.json) in `/mnt/data/cloudflare-ddns` and update the configuration to meet your needs. +4. Copy [30-cloudflare-ddns.sh](on_boot.d/30-cloudflare-ddns.sh) to `/mnt/data/on_boot.d`. +5. Execute /mnt/data/on_boot.d/[30-cloudflare-ddns.sh](on_boot.d/30-cloudflare-ddns.sh) +7. Execute `podman logs cloudflare-ddns` to verify the continer is running without error (ipv6 warnings are normal). + +### Useful commands + +```sh +# view cloudflare-ddns logs to verify the continer is running without error (ipv6 warnings are normal). +podman logs cloudflare-ddns +``` + diff --git a/cloudflare-ddns/configs/config.json b/cloudflare-ddns/configs/config.json new file mode 100644 index 0000000..e467f9d --- /dev/null +++ b/cloudflare-ddns/configs/config.json @@ -0,0 +1,20 @@ +{ + "cloudflare": [ + { + "authentication": { + "api_token": "cloudflare_api_token_here", + "api_key": { + "api_key": "api_key_if_you_don't_have_a_token", + "account_email": "your_email_here_if_you_don't_have_a_token" + } + }, + "zone_id": "your_zone_id_here", + "subdomains": [ + "each", + "subdomain" + ], + "proxied": false, + "ttl": 120 + } + ] +} diff --git a/cloudflare-ddns/on_boot.d/30-cloudflare-ddns.sh b/cloudflare-ddns/on_boot.d/30-cloudflare-ddns.sh new file mode 100644 index 0000000..f2ff1ca --- /dev/null +++ b/cloudflare-ddns/on_boot.d/30-cloudflare-ddns.sh @@ -0,0 +1,15 @@ +#!/bin/sh +CONTAINER=cloudflare-ddns + +# Starts a cloudflare ddns container that is deleted after it is stopped. +# All configs stored in /mnt/data/cloudflare-ddns +if podman container exists "$CONTAINER"; then + podman start "$CONTAINER" +else + podman run -i -d --rm \ + --net=host \ + --name "$CONTAINER" \ + --security-opt=no-new-privileges \ + -v /mnt/data/cloudflare-ddns/config.json:/config.json \ + timothyjmiller/cloudflare-ddns:latest +fi