Skip to content

Instantly share code, notes, and snippets.

@troyfontaine
Last active December 22, 2022 16:04
Show Gist options
  • Save troyfontaine/7e6f93e32621177fc9a94e823adc52b5 to your computer and use it in GitHub Desktop.
Save troyfontaine/7e6f93e32621177fc9a94e823adc52b5 to your computer and use it in GitHub Desktop.
USG ddclient Upgrade Script

How to use this script?

Why, that's simple! Copy this script to your USG, run chmod +x on it and then, as a user with sudo permission, execute it.

Shamelessly borrowed from Brittanic on the Ubiquiti Unifi forums

How to use it?

Simply run the following command (note, if you are at all security concious-don't run it and instead review the script, then copy it to your USG to execute).

curl https://gist.githubusercontent.com/troyfontaine/7e6f93e32621177fc9a94e823adc52b5/raw/fix_ddns.sh | sudo bash

But I don't see Cloudflare in the Unifi Controller!

Well you won't? This updates the client-so you still need to use the config file method of telling the USG to use ddclient to talk to Cloudflare.

Why do I need it smart guy?

If you haven't heard, Cloudflare deprecated their older API in favor of their newer-so the old ddclient still included in the Unifi line of routers can't talk to it anymore.

For those of us who use Cloudflare for DDNS-it kinda sucked. This helped.

Does this support the newer tokens?

Yes! While the pinned version of ddclient says it is 3.9.1, commenters have tested and confirmed that it has been patched to support the Cloudflare Tokens.

Details?

The token has been tested with All zones - Zone:Read, DNS:Edit and found to work.

#!/bin/bash
# Run this script as root
[ -z "$PS1" ] && return
source /etc/bash_completion
if [ "$_OFR_CONFIGURE" == ok ]; then
complete -D -F vyatta_config_default_complete
else
complete -D -F _vyatta_op_default_expand
fi
# Add deb repo to sources list if it isn't there
grep -q -F "deb http://archive.debian.org/debian/ wheezy main # wheezy #" "/etc/apt/sources.list" || echo "deb http://archive.debian.org/debian/ wheezy main # wheezy #" >> "/etc/apt/sources.list"
# Run Apt update
apt-get update
apt-get -y install libdata-validate-ip-perl dnsutils --no-install-recommends
# Download new ddclient and replace the existing version
pushd /tmp || return
curl -L -O https://raw.githubusercontent.com/ddclient/ddclient/6ae69a1ce688e8212b0973867b16af37f85172ef/ddclient
cp /usr/sbin/ddclient /usr/sbin/ddclient.bkp
cp ddclient /usr/sbin/ddclient
chmod +x /usr/sbin/ddclient
popd || return
# Tell the USG to update configuration and then display the status
update dns dynamic interface eth0
sleep 20
show dns dynamic status
@troyfontaine
Copy link
Author

Shamelessly borrowed from Brittanic on the Ubiquiti Unifi forums

should be?:

Updated!

@tsopokis
Copy link

I found the script used in ERL devices and it doesn't need any other packages, just download the file and put it under /usr/sbin/ddclient.
https://dl.ubnt.com/firmwares/edgemax/afomins/ddlient-with-cloudflare-v4-api-support-000/ddclient

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment