Skip to content

Instantly share code, notes, and snippets.

@mkyung
Forked from tehpeh/ddclient-cloudflare-macosx.md
Last active August 29, 2015 14:24
Show Gist options
  • Save mkyung/596b162f0e932814425e to your computer and use it in GitHub Desktop.
Save mkyung/596b162f0e932814425e to your computer and use it in GitHub Desktop.

Description

Dyn's free dynamic DNS service will be ending on Wednesday, May 7th, 2014.

CloudFlare, however, has a little known feature that will allow you to update your DNS records via API or a command line script called ddclient. This will give you the same result, and it's also free.

Unfortunately, ddclient does not work with CloudFlare out of the box. There is a patch available and here is how to hack[1] it up on Mac OS X.

Update (4th July, 2015)

ddclient 3.8.3 officially supports cloudflare, no more patching needed (hooray!) The following documentation is for Homebrew (The repo is currently hosting 3.8.2)

Requirements

Homebrew, basic command line skills, and a domain name that you own.

CloudFlare

Sign up to CloudFlare and add your domain name. Follow the instructions, the default values it gives should be fine.

You'll be letting CloudFlare host your domain so you need to adjust the settings at your registrar.

If you'd like to use a subdomain, add an 'A' record for it. Any IP address will do for now.

Let's get to business...

Installation

$ brew install ddclient

Patch

$ sudo cpan install JSON::Any
$ curl -O http://blog.peter-r.co.uk/uploads/ddclient-3.8.0-cloudflare-22-6-2014.patch
$ patch /usr/local/opt/ddclient/sbin/ddclient < ddclient-3.8.0-cloudflare-22-6-2014.patch

if the cpan mirror is too slow, add other mirrors from http://www.cpan.org/SITES.html

Config

$ cp /usr/local/opt/ddclient/share/doc/ddclient/sample-etc_ddclient.conf /usr/local/etc/ddclient/ddclient.conf
$ vim /usr/local/etc/ddclient/ddclient.conf

Add:

##
### CloudFlare (cloudflare.com)
###
ssl=yes
use=web, web=dyndns
protocol=cloudflare, \
server=www.cloudflare.com, \
zone=domain.com, \
[email protected], \
password=api-key \
host.domain.com

Comment out:

#daemon=300

Your api-key comes from the account page
ssl=yes might already be in that file
use=web, web=dyndns will use dyndns to check IP (useful for NAT)

Start at boot

$ sudo cp -fv /usr/local/opt/ddclient/*.plist /Library/LaunchDaemons
$ sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.ddclient.plist

You're done. Log in to https://www.cloudflare.com and check that the IP listed for your domain matches http://checkip.dyndns.com


[1] Don't do this in front of your boss.

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