Created
March 3, 2017 21:23
-
-
Save benscabbia/a6b158974219f96ecb1e87b97890c5fe to your computer and use it in GitHub Desktop.
Cloudflare + Dynamic DNS (ddclient) = Super Awesome
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This guide will show you how to configure ddclient to dynamically update your DNS at Cloudflare. | |
# This cookbook makes use of a number of online guides - all of which I will reference at the end. | |
# Cloudflare requires ddclient to be version 3.8.2 or you will get a 'cloudflare protocol didn't exist'. | |
# Unfortunately, the package manager at this time makes use of 3.8.1 | |
# My suggestion is to follow the semi-autonomous process, by downloading the out of date package | |
# and then manually update a few files. If you prefer, you can go down the fully manual route manual route. | |
# Installation - Manual (Not Tested: https://www.cloudflare.com/technical-resources/#ddclient) | |
# Installation - Semi-Autonomous (Recommended, follow below) | |
sudo apt-get update | |
sudo apt-get install ddclient libjson-any-perl | |
# The version should be 3.8.1, which does not support Cloudflare. Check version number by running the command below. | |
# Look for ...ddclient version 3.8.1 | |
ddclient -h | |
# We manually upgrade the binary along with the configuration file. Check latest version: https://sourceforge.net/projects/ddclient/ | |
# Download file: | |
wget http://downloads.sourceforge.net/project/ddclient/ddclient/ddclient-3.8.3.tar.bz2 | |
# Extract | |
tar -jxvf ddclient-3.8.3.tar.bz2 | |
# Copy the file from extracted directory and overwrite binary | |
sudo cp -f ddclient-3.8.3/ddclient /usr/sbin/ddclient | |
# From version 3.8.2 config file must be nested in a directory called ddclient, this is the final edit to our install: | |
# Move ddclient.conf in a directory called ddclient: | |
sudo mkdir /etc/ddclient | |
sudo mv /etc/ddclient.conf /etc/ddclient | |
# Awesome, we're almost there. Now just a little configuration. Navigate to directory and edit the config file: | |
cd /etc/ddclient.conf | |
sudo nano ddclient.conf | |
# Copy the configuration like below. The config assumes you have the domain 'gudthing.co.uk' | |
# Replace text in login, password, zone, and domain | |
protocol=cloudflare | |
use=web | |
server=www.cloudflare.com | |
ssl=yes | |
[email protected] | |
password=YOUR-GLOBAL-API-KEY-https://www.cloudflare.com/a/account/my-account | |
zone=gudthing.co.uk | |
gudthing.co.uk | |
# Once done, press CTRL + O to write the changes, and hit ENTER to confirm your want to overwrite file and then exit CTRL + X | |
# Good news, you are technically good to go! Test your setup by: | |
ddclient -daemon=0 -debug -verbose -noquiet | |
# Check the log and see if there are any messages. Most likely issues will be with config file, so update appropriately | |
# Now our DNS details will get updated everytime we run the command above. Pretty cool, but we can do better. | |
# Let's make it run every 5 minutes = 12 times an hour. We will do this via daemon, which will need another configuration file. | |
# Set the values to below: | |
sudo nano /etc/default/ddclient | |
run_ipup="false" | |
run_daemon="true" | |
daemon_interval=5000 | |
# Make sure you set run_ipup to false, of it will cause problems. | |
# CTRL + O and then ENTER and lastly CTRL + X | |
# Configuration ready, now lets run the daemon: | |
sudo service ddclient start | |
sudo service ddclient status | |
# Optional - Create a cron job to force daily requirement | |
# So far we have setup ddclient to run every 5 minutes. Every 5 mins it will check our WAN address and if it has changed | |
# it will talk to Cloudflare and update our DNS. The issue is that if our DNS doesn't change for a few days, then cloudflare | |
# will not hear from our server which may cause timeout issues/drops in connection or fail to update when duty calls. | |
# With a cron job, we force a daily / weekly exchange: | |
cd etc/cron.daily | |
# create a file called ddclient with the following configuration | |
sudo nano /etc/cron.daily/ddclient | |
#!/bin/sh | |
/usr/sbin/ddclient -force | |
# Write, save and close file: CTRL + O, ENTER & CTRL + X | |
# The file we've just created is just a text file, lets make it executable: | |
sudo chmod +x /etc/cron.daily/ddclient | |
# You're done! Now you can have all the benefits from Cloudflare + [free] DDNS! | |
# API Key: https://www.cloudflare.com/a/account/my-account | |
# Binary: https://sourceforge.net/projects/ddclient/ | |
# Resources: | |
# https://www.cloudflare.com/technical-resources/#ddclient | |
# https://jenssegers.com/84/dynamic-dns-for-cloudflare-with-ddclient | |
# https://samhobbs.co.uk/2015/01/dynamic-dns-ddclient-raspberry-pi-and-ubuntu |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Configure it to update only a single subdomain - say it's "ddns.domain.com". Then create CNAME records that point to "ddns".
Example: