What's new

DDNS script example to update CloudFlare not working

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

AppleBag

Regular Contributor
Hi

I copied/pasted verbatim, the CF example script (here) to update my "A" record.

Edited the respective areas, placed it in my jffs/scripts folder and set it's permissions executable. Now in the logs it says it's failing:

--

Apr 6 20:39:57 start_ddns: update CUSTOM , wan_unit 0
Apr 6 20:39:57 custom_script: Running /jffs/scripts/ddns-start (args: 12.12.12.12)
Apr 6 20:39:59 ddns: Custom ddns update failed

--

I'm not super-schooled in either bash scripting or linux, but I grabbed a copy of Cygwin and tried to run the script locally, and it also shows it's failing. Here is how my actual script looks (the keys.ids, email & domain have been randomly changed to 'anon' them, but my actual script has the real ones there.)

--

#!/bin/sh

EMAIL="mycfemail@gmail.com"
ZONEID="3d232432434343243e0f3c16d0e536ac"
RECORDID="12123432428780"
RECORDNAME="my.domain.org"
API="d5188c2132323132112324e1c811108a000f"
IP=${1}

curl -fs -o /dev/null -X PUT "https://api.cloudflare.com/client/v4/zones/$ZONEID/dns_records/$RECORDID" \
-H "X-Auth-Email: $EMAIL" \
-H "X-Auth-Key: $API" \
-H "Content-Type: application/json" \
--data "{\"type\":\"A\",\"name\":\"$RECORDNAME\",\"content\":\"$IP\",\"ttl\":120,\"proxied\":false}"

if [ $? -eq 0 ]; then
/sbin/ddns_custom_updated 1
else
/sbin/ddns_custom_updated 0
fi

--

Any idea what's wrong?

TIA
 
I'd be suspicious of the URL in the PUT. I doubt it should include cli...

Sent from my Nexus 7 using Tapatalk
 
I came across this thread when I was looking for a Cloudflare DDNS script I could use for my set up. I didn't troubleshoot the OP's thread, but I did create a working DDNS script.

https://github.com/ulygit/asus_rt_ac68u

Please let me know if you find any errors or omissions.

Also, quickly looking at the OP's pasted code, I'd recommend removing the "-o /dev/null" arguments so you can see the output response from the Cloudflare service. It's possible Cloudflare is reporting an error, but it's being discarded.
 
I am trying to do this, but I have two questions if I may :
1 - Where do I find the zoneID ?
2 - I have a large number of subdomains, so many A records, so how do I do that ?
Thanks.

edit- found the zoneID - just Q2 now......
 
Last edited:
OK - answered number 2 myself by modifying my domain DNS. Instead of all those A records, I changed them to cname's pointing to the one A records that has the IP address. Then only one to update. I guess this is the 'correct' way I should have done it in the first place - seeing as they all use the same IP address......
 
Hi,
i have a domain at CF, example.net and all the subdomains are CNAME, like test.example.net
What should I configure as A tpye in CF DNS?
And in the script?
 
Hi,
i have a domain at CF, example.net and all the subdomains are CNAME, like test.example.net
What should I configure as A tpye in CF DNS?
And in the script?

Mine looks like this:

Code:
;; A Records
my.home.domain.    120    IN    A    123.123.123.123 <--- my home IP

;; CNAME Records
bitwarden.home.domain IN    CNAME    my.home.domain.
ftp.home.domain    IN    CNAME    home.domain.
grafana.home.domain    IN    CNAME    my.home.domain.
plex.home.domain    IN    CNAME    my.home.domain.
prometheus.home.domain    IN    CNAME    my.home.domain.
resilio-sync.home.domain    IN    CNAME    my.home.domain.
sourcegraph.home.domain    IN    CNAME    my.home.domain.
syncthing.home.domain    IN    CNAME    my.home.domain.


My A record points to my home IP, with a subdomain name I use just for it, in this example "my" is the subdomain name. After that, any time I want to add any other subdomain name (I run docker containers that I point to with them) I just add a ncew cname that points to the "my" subdomain, which in turn uses my home IP. I also have a script that checks daily if my home IP changed, and if so, updates that A record for me automatically.
 
Mine looks like this:

Code:
;; A Records
my.home.domain.    120    IN    A    123.123.123.123 <--- my home IP

;; CNAME Records
bitwarden.home.domain IN    CNAME    my.home.domain.
ftp.home.domain    IN    CNAME    home.domain.
grafana.home.domain    IN    CNAME    my.home.domain.
plex.home.domain    IN    CNAME    my.home.domain.
prometheus.home.domain    IN    CNAME    my.home.domain.
resilio-sync.home.domain    IN    CNAME    my.home.domain.
sourcegraph.home.domain    IN    CNAME    my.home.domain.
syncthing.home.domain    IN    CNAME    my.home.domain.


My A record points to my home IP, with a subdomain name I use just for it, in this example "my" is the subdomain name. After that, any time I want to add any other subdomain name (I run docker containers that I point to with them) I just add a ncew cname that points to the "my" subdomain, which in turn uses my home IP. I also have a script that checks daily if my home IP changed, and if so, updates that A record for me automatically.

Thanks
But which script should I use on the router (Asus Merlin John's Fork) to update dns with CF directly? I saw many scripts and forks of them, which one should I use?
 

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top