mirror of
https://github.com/qdm12/ddns-updater.git
synced 2026-08-02 10:38:41 -04:00
Bug: Cannot get Record ID, Cloudflare DNS #140
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @SuperJakish on GitHub (Sep 12, 2021).
Originally assigned to: @qdm12 on GitHub.
TLDR: Cannot get Record ID, Cloudflare DNS
Is this urgent: No
DNS provider(s) you use: Cloudflare
Program version: Running version latest built on 2021-09-10T22:10:33Z (commit
8b327f8)What are you using to run the container: docker-compose
I've been trying a few different config.json versions starting with the one in the example here, but it looks like Cloudflare has changed the way they authenticate from when this was written. Either that or I'm just not smart enough to put in the right keys/tokens. I was able to pull my ID using instructions from Cloudflare's API page which now uses Bearer to authenticate rather than X-Auth-Email and X-Auth-Key as in this documentation. The new call looks like this:
Logs:
Configuration file (remove your credentials!):
Host OS: Ubuntu 20.04
@qdm12 commented on GitHub (Sep 12, 2021):
Hi there! Thanks for the detailed issue.
I checked their official documentation and it looks it's the same as before. From their curl example:
And that's how they are set in the code of this program:
01f4044404/internal/settings/providers/cloudflare/provider.go (L128-L139)I doubt Cloudflare would break this behavior without releasing a
v5version of their API too.In addition, the error you get:
Looks like Cloudflare doesn't reply at all. If it would be an authentication error, you would get a
401or403http status code as a response.What are your thoughts? 🤔
@SuperJakish commented on GitHub (Sep 12, 2021):
Okay, so when I started writing this bug report, I had my config host set to
"host": "*",which gave me a403authentication error:When I switch host to
"host": "@",, I get the timeout error as above:I'm not certain which I should be using, but my configuration uses a series of subdomains (sub1.mydomain.com; sub2.mydomain.com; etc).
@qdm12 commented on GitHub (Sep 12, 2021):
Ok from Cloudflare's docs, you can use a
nameurl parameter which ddns updater uses to narrow down the record id result to a single one. Now the problem is that it builds that name parameter as*.domain.comandhost.domain.comfor wildcard and subdomain records respectively I think. The Cloudflare doc doesn't specify if this is meant to be or not. My guess is that it can only be domain.com. That would explain the 403 for wildcards at least, and maybe their api crashes or something with two dots who knows 😄To confirm that, would you be able to try curling the api as you did but using the url query parameter
?name=*.yourdomain.comand another with?name=yourhost.yourdomain.comsee if it works or not?EDIT: also can you try with the @ host on your domain and the program as it is perhaps to see if it works or not?
If it doesn't, I'll change the code to use only the domain.tld as the name query parameter and filter the multiple results obtained from cloudflare.
@SuperJakish commented on GitHub (Sep 12, 2021):
Okay - you've crashed through the boundary of my understanding, but here is my attempt at following through with something useful. I curled the API using the following commands with the corresponding results:
First with just my domain (mydomain.com):
Next with *.mydomain.com:
and finally with @.mydomain.com:
If this isn't what you're looking for, would you kindly please give the complete command you'd like me to execute?
@qdm12 commented on GitHub (Sep 18, 2021):
Hi there sorry I lost track of the issue.
Try with:
Replacing your zone id, domain name, auth email and auth key.
You should get at least one record, ideally multiple including the wildcard one 🤔
If you do I'll adapt the code to extract the right record id.
@SuperJakish commented on GitHub (Sep 19, 2021):
That seemed to work. Here is the result:
@qdm12 commented on GitHub (Sep 20, 2021):
Ok interesting. Try pulling image
qmcgaw/ddns-updater:243, it now lists records from cloudflare using"name": "domain.com"instead of"name": "sub.domain.com"(or"*.domain.com"), so that will solve at least the get records part. I'm not sure the update with"name": "*.domain.com"would work since Cloudflare doesn't precise how wildcards should be handled.Actually, if it doesn't work, try with
curlnow that you have your single record ID ("id":"<IDENTIFIER>") using the command you used above:And fiddle with the
"name": "*.domain.com"portion to see how this command succeeds. Note that if this works, it updates your wildcard record to127.0.0.1. Thanks!!PS: Also alternatively, Cloudflare supports DNS-O-Matic so you could use that instead since ddns-updater supports dns-o-matic.
@SuperJakish commented on GitHub (Sep 20, 2021):
Alrighty - tried to pull :243 with the following failure:
Also tried the curl command
With the following failure:
FWIW, I tried with
*.<DOMAIN>and just<DOMAIN>for the"name"entry with the same results.I'll check out DNS-O-Matic this weekend to see if I can get that working. Thanks for the tip there!
@qdm12 commented on GitHub (Sep 23, 2021):
Sorry for the dumb question, but did you replace
<ZONE-ID>and<RECORD-ID>in the url? If you check their API docs at the Update DNS Record section, it should accept a PUT request as you wrote that curl command... 🤔What's your machine / cpu architecture? I just pushed it for amd64 that's probably why.
@SuperJakish commented on GitHub (Sep 25, 2021):
I did replace them, but apparently not with the correct thing. Re-checking the API doc, I found that I had used the wrong thing in the
<RECORD-ID>section. That is actually the<IDENTIFIER>. So, now with the correct entries, here's what it looked like for<DOMAIN>:and for
*.<DOMAIN>:There was a problem with the
*.<DOMAIN>because it correctly showed*.<DOMAIN>in the output"name"field, but the name on the Cloudflare portal was only*and none of the subdomain CNAME entries routed properly. I think that means just<DOMAIN>is preferred.The second thing here is that I run my domain proxied through Cloudflare and this script reverts the domain to DNS Only (not proxied). I recall you have a setting in the config for the proxy setting and this is probably covered - just wanted to mention it if some other functionality was expected.
Otherwise, I was able to successfully update the A record with an IP address.
I'm runing on
x86_64.@qdm12 commented on GitHub (Sep 26, 2021):
So does that mean you cannot update
*.<DOMAIN>alone and need to update all A records for<DOMAIN>together? Or that each subdomain hosts (including wildcard*) need to be CNAME records and cannot be A/AAAA records? If that's the case, for now the program doesn't supportCNAMErecords but I can change that if it's actually required for Cloudflare and subdomains/wildcard.Oops sorry, maybe it was also me misleading you!
If you want to test, you can just add
"proxied": trueto the JSON body (after that-dflag in the curl command) to update it and keep it proxied 😉 And yes it's covered in this program.Oh Ok yes, I forgot to push it oops! 🤔 It's pushed now!
@SuperJakish commented on GitHub (Sep 26, 2021):
In Cloudflare, all the subdomains are CNAME records that point to the A record. The A record is the only one that needs to be updated, so
<DOMAIN>looks to be sufficient. I may have led us on a wild goose chase with the subdomain thing. That subplot can be dropped when this is turned into a movie.Okay, I pulled down 243 and everything looks good. It successfully updated and proxied the A record as expected. I tried with both
*and@host options with no difference in the result, though the log did have a difference.For Host
@:And for Host
*:Here is a look at my settings.json:
Thanks very much for your patience in working through this with me! I think it's working!
@qdm12 commented on GitHub (Sep 27, 2021):
That made me laugh quite a bit 😄
Good I'll merge it in the latest image before closing this issue.
Likewise, thanks for the long debugging!
One last question, so are you telling me you cannot have different subdomains with different ip addresses with Cloudflare? If that's the case, removing subdomain and wildcard options would be good for this program.
@SuperJakish commented on GitHub (Sep 27, 2021):
I'm not exactly sure, but here is what I found when making the API token. I had to create the token and then could restrict it to either a single specific zone, all zones, or zones only affiliated with my account (email address). This was configured at the token level. So if I had 2 zones that each pointed to different IP addresses, I'd only want to update the DNS of the specific zone (based on the Zone ID). The token would only have permission to edit that zone for added security.
I'm not sure how other people use this updater, but I've only got the one zone I'm worrying about, so all the subdomains point to the same A record. Based on this, if I had different servers with different IPs, I'd think DDNS Updater would need to be running locally on each of them, so it wouldn't be worth supporting the wildcards as each server would update it's own zone.
Your mileage may vary.
@qdm12 commented on GitHub (Oct 2, 2021):
Alright, I think I'll leave it as it is just in case it's actually used somehow by someone and to avoid breaking compatibility.
87f06eeb28adds documentation on thathostparameter for Cloudflare and links up to your comment for context, thanks for that. Let's close the issue for now 😉 Thanks again for your patience and debugging!@TheVooDooDaddy commented on GitHub (Apr 28, 2022):
I was able to get this to work with two separate domains and www subdomains. Leave the "host" as "@" and then add the subdomain to the "domain". My config.json file is below:
@jk-andersen commented on GitHub (Jun 9, 2023):
Just to add on that. This works now with the API.
My config:
https://i.imgur.com/OLMjwH2.png
@qdm12 commented on GitHub (Jun 12, 2023):
@jk-andersen Does it work with any subdomain such as
abcfor the"host"parameter?@jk-andersen commented on GitHub (Jun 12, 2023):
After a fast smoke-test I would say yes:
https://i.imgur.com/chyNw1T.png
@qdm12 commented on GitHub (Jun 12, 2023):
Awesome @jk-andersen I documented it in the docs/Cloudflare.md document 👍
@baaa commented on GitHub (Jul 19, 2023):
I'll drop this line of comment here for people like me and landed on this page.
I was getting this same error message and while debugging I noticed you are querying only for "A" records.
I had a CNAME configured for wildcard where * was pointing to domain.com, so your query naturally found nothing. Only after deleting the CNAME on cloudflare and adding an A record for wildcard this started working.
honestly this is an oversight/error on my side, as it literally makes no sense to "update the ip address of a CNAME" since a CNAME is a resolution from name to name.