-
-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Cannot get Record ID, Cloudflare DNS #243
Comments
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: curl -X GET "https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records?type=A&name=example.com&content=127.0.0.1&proxied=undefined&page=1&per_page=20&order=type&direction=desc&match=all" \
-H "X-Auth-Email: user@example.com" \
-H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \
-H "Content-Type: application/json" And that's how they are set in the code of this program: ddns-updater/internal/settings/providers/cloudflare/provider.go Lines 128 to 139 in 01f4044
I doubt Cloudflare would break this behavior without releasing a 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 What are your thoughts? 🤔 |
Okay, so when I started writing this bug report, I had my config host set to
When I switch host to
I'm not certain which I should be using, but my configuration uses a series of subdomains (sub1.mydomain.com; sub2.mydomain.com; etc). |
Ok from Cloudflare's docs, you can use a To confirm that, would you be able to try curling the api as you did but using the url query parameter 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. |
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? |
Hi there sorry I lost track of the issue. Try with: curl -X GET "https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/dns_records?type=A&name=example.com" \
-H "X-Auth-Email: user@example.com" \
-H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \
-H "Content-Type: application/json" 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. |
That seemed to work. Here is the result:
|
Ok interesting. Try pulling image Actually, if it doesn't work, try with curl -X PUT -d '{"type": "A", "name": "*.domain.com", "content": "127.0.0.1", "ttl": 3600}'
"https://api.cloudflare.com/client/v4/zones/<ZONE-ID>/dns_records/<RECORD-ID>" \
-H "X-Auth-Email: <EMAIL>" \
-H "X-Auth-Key: <GLOBAL API KEY>" \
-H "Content-Type: application/json" And fiddle with the PS: Also alternatively, Cloudflare supports DNS-O-Matic so you could use that instead since ddns-updater supports dns-o-matic. |
Alrighty - tried to pull :243 with the following failure:
Also tried the curl command
With the following failure:
FWIW, I tried with I'll check out DNS-O-Matic this weekend to see if I can get that working. Thanks for the tip there! |
Sorry for the dumb question, but did you replace
What's your machine / cpu architecture? I just pushed it for amd64 that's probably why. |
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
and for
There was a problem with the 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 |
So does that mean you cannot update
Oops sorry, maybe it was also me misleading you!
If you want to test, you can just add
Oh Ok yes, I forgot to push it oops! 🤔 It's pushed now! |
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 Okay, I pulled down 243 and everything looks good. It successfully updated and proxied the A record as expected. I tried with both 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! |
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. |
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. |
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. 87f06ee adds documentation on that |
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:
|
Just to add on that. This works now with the API. My config:
|
@jk-andersen Does it work with any subdomain such as |
After a fast smoke-test I would say yes:
|
Awesome @jk-andersen I documented it in the docs/Cloudflare.md document 👍 |
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. 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. |
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
The text was updated successfully, but these errors were encountered: