Forget what I said, ddclient is best for your EdgeRouter with Cloudflare DDNS
2023-07-05
- Updated to v2.0.9-hotfix.7
and had ddclient
parse error
2021-05-23
- added link / information to force update DDNS
In a prior post I wrote that one can use the in-built cron
jobs of your edgerouter in order to send curl
commands to update DNS records to point at your router. This solution was rock solid for me, but does a lot of things that are actually unnecessary.
What I didn't know at the time is that the EdgeRouter X also supports ddclient
and so does Cloudflare. This requires a lot less set up and doesn't require any finangling of the EdgeRouter X config from the terminal / ssh (unless you'd like to). Overall, having to enter the config this way is quite annoying when you don't have access to vim
or nano
to edit or any standard gnutools for interacting with paths and directories.
Taking a few steps back, ddclient
is a dynamic DNS client written in Perl that was formely hosted on the infamous Sourceforge. However, between me setting up it up and this blog post, they've since moved to Github.
https://github.com/ddclient/ddclient
This client is included in EdgeRouter X and it can speak to a whole host of various DNS providers. Rather than maintain my custom curl
setup with cron
jobs this was clearly the correct choice.
I managed to get everything working via this set up below. From what I could tell, Cloudflare used to have more robust documentation here on how to interact with their API via ddclient
but it took some piecing together from blog posts as well as what remains of the official documentation. Here is my configure
and then show service dns
while ssh
'd into the EdgeRouter X.
dns {
dynamic {
interface pppoe0 {
service custom-cloudflare {
host-name <subdomain>.dalanmiller.com
host-name blog.dalanmiller.com
host-name "*.<subdomain>.dalanmiller.com"
login <cloudflare_email_address>
options "zone=dalanmiller.com use=web ssl=yes ttl=1"
password <cloudflare_api_key_here>
protocol cloudflare
server api.cloudflare.com/client/v4
}
}
}
}
I took nearly this same config and installed ddclient
on a Raspberry Pi to achieve the same effect for another network I wanted to be able to route DNS entries towards.
Overall, been running this setup for over a year now without any issues.
Ongoing Fixes:
On 2021-05-23
, I finally ran into a weird case where only one of the three records I was updating on Cloudflare were updating correctly. Restarting the router did not alleviate this. I ended up SSH'ing into the router (from horrible hospital wifi no less) and checking the logs:
noconnect
! What is that? Clearly, it was failing on subsequent domains or Cloudflare was having some sort of issue handling the request. Luckily, I found this article over at ui.com which gave me the proper command to force an update.
And then all was right again ✅.
On 2023-07-06
I updated to the latest hotfix v2.0.9-hotfix.7
and had the following error in my logs.
cat /var/logs/messages
...
Jul 5 07:31:44 edgerouter ddclient[29991]: WARNING: file /var/cache/ddclient/ddclient_pppoe0.cache, line 4: Invalid Value for keyword 'ip' = ''
Looking at /var/cache/ddclient/ddclient_pppoe0.cache
I couldn't see anything at reasonably at issue. But given that the file ended in .cache
I decided to rm
the file and rerun the update command. This seemed to fix everything after running the update command again.