Cloudflare dynamic dns not working
-
I Upgraded to pfsense 2.2 release the other day in hopes of using the built in cloudflare dynamic dns updater.
I entered all my info and the cached ip keeps showing up as 0.0.0.0
config entered in format below:Service type: Cloudflare
Interface: WAN
Hostname: mydomain.com
Username: user@somedomain.com
Password: mycloudflarepwObviously I entered my real domain and credentials into the dynamic dns client.
I have google dns setup in General setup of pfsense.
I have triple checked the credentials and forced updates and rebooted the whole thing a few times yet it still isn't properly updating. -
I can confirm that this is broken. It worked perfect at one point during the 2.2betas then a few betas later pfsense stopped updating what the ip is, but was still updating cloudflare. Then they released the final version and broke this among so many other things.
I do not understand what was changed, but the last RC is much better than this release.
I think that you have to use the api key as your password though the interface for the ddns does not say this. But not sure as 2.2 final wont load with my config that worked all the way up through the last RC, so can't be 100% how I had it.
-
Not working for me either.
This is the entry in my log:
Feb 3 18:19:51 php-fpm[51765]: /services_dyndns_edit.php: DynDNS: PAYLOAD: E_INVLDINPUT
Feb 3 18:19:51 php-fpm[51765]: /services_dyndns_edit.php: DynDNS: (Unknown Response)
Feb 3 18:19:51 php-fpm[51765]: /services_dyndns_edit.php: DynDNS: (Unknown Response)Any way to alert someone higher up to see what is going on?
-
This post is deleted! -
This post is deleted! -
I guess you could also create a custom dynamic dns provider and pass a URL like this:
https://www.cloudflare.com/api.html?a=DIUP&hosts=example.com&u=username@email.com&tkn=abc123abc&ip=%IP%
Otherwise if you need any testing done to submit a patcvh let me know. I am keen to get this working but a bit out of my depth.
-
If it is just the URL format that needs changing then it should be a 1-line fix.
Try this change to /etc/inc/dyndns.class
https://github.com/phil-davis/pfsense/commit/08edc860bd2eb3ee98660f585e33d603d985571fIf it works, then I can submit a pull request for it.
-
I have made the changes above and still getting the logs below:
Feb 18 14:56:20 php-fpm[8912]: /services_dyndns_edit.php: DynDns: updatedns() starting Feb 18 14:56:21 php-fpm[8912]: /services_dyndns_edit.php: DynDns (bonkas.kiwi.nz): x.x.x.x extracted from local system. Feb 18 14:56:21 php-fpm[8912]: /services_dyndns_edit.php: DynDNS (bonkas.kiwi.nz): DynDns _update() starting. Feb 18 14:56:23 php-fpm[8912]: /services_dyndns_edit.php: DynDNS (bonkas.kiwi.nz): DynDns _checkStatus() starting. Feb 18 14:56:23 php-fpm[8912]: /services_dyndns_edit.php: DynDNS (bonkas.kiwi.nz): Current Service: cloudflare Feb 18 14:56:23 php-fpm[8912]: /services_dyndns_edit.php: DynDNS: PAYLOAD: E_INVLDINPUT Feb 18 14:56:23 php-fpm[8912]: /services_dyndns_edit.php: DynDNS: (Unknown Response) Feb 18 14:56:23 php-fpm[8912]: /services_dyndns_edit.php: DynDNS: (Unknown Response)
-
I sent this in a URL to test what comes back:
https://www.cloudflare.com/api.html?a=DIUP&hosts=test.cloudflare.com&u=testuser@email.com&tkn=test123token&ip=1.2.3.4
and it responded with:
E_INVLDINPUT You must include an `a' parameter, with a value of wl|chl|nul|ban|comm_news|devmode|sec_lvl|ipv46|ob|cache_lvl|fpurge_ts|async|mirage2|img.q|minify|stats|zone_check|zone_ips|zone_ss|vote_ss|app|ip_lkup|set|app_req|app_req_list|app_version|custom_cert_set|custom_cert_purge|custom_cert_load_multi|custom_cert_load|ersubmit|zoneupload|user_notification_remove|pref_set|zone_file_purge|zone_file_refresh|zone_settings Additionally, email and tkn parameters are required. _________________________________
So "a=DIUP" is not valid, and it seems that the suggested "u=username" should still be the old "email=".
Get a URL string that actually works for you by trying just in the browser bar. Then change your username(email) and tkn(password) to protect them and whatever other data (put a bogus domain name and IP if you like), and post what URL string format actually works.
Then we can code that in dyndns.class -
This post is deleted! -
You should be able to split the domain out (the "z" parameter) from the host with a bit of separating-the-dots code. That will provide that parameter from the variable you already have.
The tricky part looks to be the "id" parameter - do you have to do a "rec_load_all call" to get all your records back, loop through it and find the "id" of the record you want to update?
Don't they have a simpler way? It seems to me that record type, record name, content, user name, password, other record parameters (ttl…) should be enough for them to match and update a record. -
Im going to work on getting a correct URL tonight with reference to the new API and see if I can get this updating with at least a custom Dynamic DNS entry.
Will see how I go.
EDIT:
After attempting this I am receiving the following back from the API:
You must include an `a' parameter, with a value of wl|chl|nul|ban|comm_news|devmode|sec_lvl|ipv46|ob|cache_lvl|fpurge_ts|async|mirage2|img.q|minify|stats|zone_check|zone_ips|zone_ss|vote_ss|app|ip_lkup|set|app_req|app_req_list|app_version|custom_cert_set|custom_cert_purge|custom_cert_load_multi|custom_cert_load|ersubmit|zoneupload|user_notification_remove|pref_set|zone_file_purge|zone_file_refresh|zone_settings
Additionally, email and tkn parameters are required.It's as if the paremeters for "a" are not being recognised by the API, these may have changed from what is documented in the API documentation?
Either thaat or I am doing something wrong.
-
There seems to be some confusion on what the valid parameters are for the cloudflare client api. So just to help get this ball moving in the right direction here are the relevant parts of the api.
Link to full api - https://www.cloudflare.com/docs/client-api.html#s5.22 - Client Operations
All GET/POST requests should be directed at the client gateway interface, located at:https://www.cloudflare.com/api_json.html
2.1 - Basic Parameters
Every GET/POST request must include at the following basic parameter(s):"tkn" - This is the API key made available on your Account page.
"email" - The e-mail address associated with the API key.
"a" - To define which request is being made, the client should POST an "a" parameter. The "a" specifies which action you'd like to perform. Specific actions are described in Section 3 below.5.2 - "rec_edit" – Edit a DNS record
Edit a DNS record for a zone. The record will be updated to the data passed through arguments here.Input:
Requires the basic parameters described in Section 2.1 of this document. In addition you must pass the following parameters:"z" - The target domain
"type" - Type of DNS record. Values include: [A/CNAME/MX/TXT/SPF/AAAA/NS/SRV/LOC]
"id" - DNS Record ID. Available by using the rec_load_all call.
"name" - Name of the DNS record.
"content" - The content of the DNS record, will depend on the the type of record being added
"ttl" - TTL of record in seconds. 1 = Automatic, otherwise, value must in between 120 and 86400 seconds.
"service_mode"[applies to A/AAAA/CNAME] - Status of CloudFlare Proxy, 1 = orange cloud, 0 = grey cloud.The minimum amount of information that you would need to provide an update for foo.bar.com with the current IPv4 address is:
tkn=CLOUDFLAREAPI
email=me@bar.com
a=rec_edit
z=bar.com
type=A
name=foo
content=%IP%To manually update the IP for foo.bar.com you should be able to run the following -
curl https://www.cloudflare.com/api_json.html?a=rec_edit&tkn=CLOUDFLAREAPI&email=me@bar.com&a=rec_edit&z=bar.com&type=A&name=foo&content=%IP% -
You must include an `a' parameter, with a value of wl|chl|nul|ban|comm_news|devmode|sec_lvl|ipv46|ob|cache_lvl|fpurge_ts|async|mirage2|img.q|minify|stats|zone_check|zone_ips|zone_ss|vote_ss|app|ip_lkup|set|app_req|app_req_list|app_version|custom_cert_set|custom_cert_purge|custom_cert_load_multi|custom_cert_load|ersubmit|zoneupload|user_notification_remove|pref_set|zone_file_purge|zone_file_refresh|zone_settings Additionally, email and tkn parameters are required.
That message that comes back interactively doesn ot mention "rec_edit" at all. Someone who uses Cloudflare should tell them that the message is old/out-of-date - because that causes confusion to people trying to get their client working!
curl https://www.cloudflare.com/api_json.html?a=rec_edit&tkn=CLOUDFLAREAPI&email=me@bar.com&a=rec_edit&z=bar.com&type=A&name=foo&content=%IP%
"a=rec_edit" got repeated twice in there - I guess it will not break? But should not be necessary.
Someone post an actual successful update URL string (with their password "tkn" and domain name obfuscated) and then we can easily make the pfSense code do the correct thing.
-
For me it wasn't working either, because you need to add the record_id, which you need to request with the rec_load_all API function before.
I extended the dyndns.class in /etc/inc/, so now it's working for me.
I can now use the Web-Interface, albeit MX and Wildcards are not working.
It's a rather dirty fix imo, but it's working, for me ;D.Edit:
I'm running
2.2-RELEASE (amd64)
built on Thu Jan 22 14:03:54 CST 2015
FreeBSD 10.1-RELEASE-p4 -
Hello,
… So we have some new update for this planned... ? :-\
ps : for people like me who cannot wait for pfs cloudflare, try this => http://www.ubuntugeek.com/how-to-use-cloudflare-as-a-ddclient-provider-under-ubuntu.html ... It works! :D
-
Thank you. Great first post & welcome to the forums! Works for me too, hopefully this will get rolled into pfSense soon.
For me it wasn't working either, because you need to add the record_id, which you need to request with the rec_load_all API function before.
I extended the dyndns.class in /etc/inc/, so now it's working for me.
I can now use the Web-Interface, albeit MX and Wildcards are not working.
It's a rather dirty fix imo, but it's working, for me ;D.Edit:
I'm running
2.2-RELEASE (amd64)
built on Thu Jan 22 14:03:54 CST 2015
FreeBSD 10.1-RELEASE-p4 -
I didn't like how much was hardcoded, so here is what I did to get it working on mine. I am currently running 2.2 but the fork/commit is based on the current master. The majority of this was from brainlesscurls: https://github.com/brainlesscurls/pfsense/commit/4f3ce17b98919e464044cbc983e31549b595bdc3
Here is the code that I created, it does not correctly handle the response coming back or check if cached differs at all:
https://github.com/pivconcto/pfsense/commit/40400bd172ae1097b5c0db540cf4dde20e9f78d7
-
I have sorted this not after a lot of research.
I stumbled across this website: http://blog.t-m-s.co.uk/ with a blog post with exactly our issue and solution with a very good explanation on the use of the CloudFlare API.
I recommend reading through this completely to understand what is going on.
After following the steps in the website and tweaking a few things to cater for my needs it's up and running beautifully.
-
I actually worked out a fix at the dyndns.class file:
CloudFlare now requires a "record ID" in order to update an address, for such I did another curl call before pfsense change of the IP in order to get the record ID from the target.
Also the CloudFlare URL is quite different from the one in the original file of pfSense.
if you open the /etc/inc/dyndns.class, line 607, the original case looks like:
case 'cloudflare':
$needsIP = TRUE;
$dnsServer ='www.cloudflare.com';
$dnsHost = str_replace(' ','', $this->_dnsHost);
$URL = "https://{$dnsServer}/api.html?a=DIUP&email={$this->_dnsUser}&tkn={$this->_dnsPass}&ip={$this->_dnsIP}&hosts={$dnsHost}";
curl_setopt($ch, CURLOPT_URL, $URL);
break;I change it to:
case 'cloudflare':
$needsIP = TRUE;
$dnsServer ='www.cloudflare.com';
list ($host,$zone) = split('.', $this->_dnsHost, 2);
$getid = "https://$dnsServer/api_json.html?a=rec_load_all&tkn={$this->_dnsPass}&email={$this->_dnsUser}&z=$zone";
$crl = curl_init();
$timeout = 5;
curl_setopt ($crl, CURLOPT_URL,$getid);
curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
$ids = curl_exec($crl);
curl_close($crl);
$json_ids = json_decode($ids, true);
$jsonIterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($json_ids),RecursiveIteratorIterator::SELF_FIRST);
$recid=0;
foreach ($jsonIterator as $key => $val) { if(!is_array($val)) { if ($key == "rec_id") { $recid=$val; } if ($key == "name" and $val == $this->_dnsHost) { break; } } }
$dnsHost = str_replace(' ','', $this->_dnsHost);
$URL = "https://{$dnsServer}/api_json.html?a=rec_edit&tkn={$this->_dnsPass}&email={$this->_dnsUser}&id=$recid&z=$zone&type=A&name=$host&content={$this->_dnsIP}&service_mode=1&ttl=1";
curl_setopt($ch, CURLOPT_URL, $URL);
break;In the Dynamic DNS interface all the information is pretty much the same, except the password must be the Token ID found at https://www.cloudflare.com/my-account ("Your API key is: ")
With this change he is automatically updating CloudFlare but the cached IP address still 0.0.0.0, something else must change to make this value also correct.
I hope this help to fix the problem for other people as well.