How to Set Up Dynamic DNS from a Raspberry Pi
14 Aug 2016Why I needed this solution
Accessing my home network has always been a nice to have. I’ve always used services such as dyndns.org, no-ip.org and the list goes on. No real solution ever stuck very long as most of the free services turn out to not be free over time. So why not update my domain directly from my network? The end-all solution!
This solution assumes you already manage your DNS using Cloudflare DNS service. I highly recommend Cloudflare for a number of reasons. They manage one of the top-performant DNS solutions in the world as per SolveDNS.com.
Why use a Raspberry Pi And not my router?
A lot of consumer-grade routers have a dynamic DNS solution. Most of these are tied to the above list of freemium dynamic DNS services. This doesn’t help us when we’re trying to avoid paying money to simply connect to our home network.
Credit Is Due
I learned a lot using the following article Jens Segers’ Blog and I’m ultimately updating it with more pictures from my experience.
Install the old ddclient
We will piggy-back off the old ddclient set up which includes start up/down scripts and configuration file samples. As well as install a Perl dependency that ddclient uses for the Cloudflare configuration.
Note: ddclient may run through some configuration wizard - it’s safe to skip the screens by just hitting the enter key on each screen.
Install the new ddclient
The latest ddclient 3.8.3 has a pull request that connects to Cloudflare using their API. We will download directly from Sourceforge and overwrite the binary.
Configuring ddclient for Cloudflare
We will now configure ddclient to use the new Cloudflare protocol. We will need our Cloudflare credentials such as our email, API key, zone and records to update.
The values I procured are as such:
- Email: [email protected]
- Password (Cloudflare API key): d7b75cd67e8f9c5x975307c5f32762287c19c
- Zone (base domain we’re updating): bitpi.co
- Subdomain we’re using to update our dynamic IP address: pi.bitpi.co
We will update the configuration file with the following configuration change (make sure to update everything between astericks):
Now we save the file and run a test to make sure we’re updating our hostname appropriately. We will run the following command:
We should hopefully see the following message: