Using dd-wrt Dynamic DNS client with CloudFlare

Solution 1:

I don't think you can set it up where DD-WRT calls CloudFlare directly. The way I have it configured is to have DD-WRT call a PHP script on a remote web server, which then detects the client IP and sends the update request to CloudFlare via their API.

DD-WRT DDNS settings

DDNS Service: Custom
DYNDNS Server: <yourserver.com>
Username: <anything>
Password: <anything>
Host Name: <your domain name to update on cloudflare>
URL: /cloudflare_update.php?key=<your secret key>&hostname=

cloudflare_update.php

if(empty($_GET['key']) || ($_GET['key'] != "<your secret key>")) die;
$hostname = $_GET['hostname'];
$ip = $_SERVER['REMOTE_ADDR'];
$username = "<[email protected]>";
$api = "<your cloudflare api key>";
$curl = "https://www.cloudflare.com/api_json.html?a=DIUP&hosts=$hostname&u=$username&tkn=$api&ip=$ip";
$ch = curl_init($curl);
curl_exec($ch);
curl_close($ch);

Instead of using HTTP basic auth I just use a random key.

Make sure you create the DNS entry for the domain name you want to update on CloudFlare; the DIUP action parameter will only update the IP for an entry that already exists.

Solution 2:

If you want to execute the update from your router then there is no getting around the fact that you need a little extra 'something' in the middle to convert your call into the CloudFlare format (if only DNS-O-Matic would add them to their supported services...). Rather than have to host an intermediate script yourself you can just use Google AppEngine (which is free) to do this re-posting for you. I use this:

https://cloudflare-updater.appspot.com/

Okay, you still have to call something other than CloudFlare to issue the update but at least you don't need to run an extra host or VPS etc. to do it yourself. It's completely transparent - only problem is that you don't get an errors returned so you need to check it's working yourself. Once it is working it should just run and run.

Solution 3:

Noticing this is all outdated and now requires v4 api code to work.

tested above an it fails - bad user,pass,xxxx info.

reviewing this method https://github.com/ScottHelme/CloudFlareDDNS