Skip to content
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

all DNS records got deleted when IPv4 not detected #60

Closed
dechunwang opened this issue Jun 18, 2021 · 15 comments
Closed

all DNS records got deleted when IPv4 not detected #60

dechunwang opened this issue Jun 18, 2021 · 15 comments
Assignees

Comments

@dechunwang
Copy link

Describe the bug
Hi there, I had facing a problem where DDNS accidentally (randomly ) deleted all my DNS records on my site.
This happened three times on three different machines that installs ddns scripts.
I set up the config as in Doc:

{
  "cloudflare": [
    {
      "authentication": {
          "api_token": "xxx" 
      },
      "zone_id": "xxx",
      "subdomains": [
        "arm"
      ],
      "proxied": false
    }
  ],
  "a": true,
  "aaaa": false
}

To Reproduce
Crontab calling start-sync.sh every 4 mins
Expected behavior
should only update subdomain's ip address

Screenshots
the log output from the script:
image
it clear shows when IPv4 not detected, the program deleted all sub-domain dns record of my site.

here is the log in clouldflare:
image

Desktop (please complete the following information):

  • OS: [Ubuntu 20.04]

Smartphone (please complete the following information):
N/A

Additional context
N/A

@JCAguilera
Copy link

Same happened to me today. Have you found any workarounds or fixes?

@mrtungdev
Copy link

Same :(

@anthonydiiorio
Copy link

Same. Was able to restore records from the audit log thankfully.

@kikkia
Copy link

kikkia commented Sep 16, 2021

I forked the repo and packaged a proposed pr to fix this. Until the pr is merged feel free to use this docker image registry.gitlab.com/kikkia/cloudflare-ddns its all open source if you want to verify what was changed.
https://gitlab.com/kikkia/cloudflare-ddns

@debMan
Copy link

debMan commented Oct 22, 2021

Shit, same issue today

🧩 IPv4 not detected
🗑️ Deleted stale record 3f769304159294fa916c0950f45fb34f
🗑️ Deleted stale record 5c8c82a396502f7005671553baf5c981
🗑️ Deleted stale record 07847081a8b7acb596dd44970a50c454
🗑️ Deleted stale record 2041129286049685224070bd98e8c232
🗑️ Deleted stale record 6afee39b8b12bf8657e6e9eefa1f10cb
🗑️ Deleted stale record c96d0c8f99f263d86c9f3c148784786b

@osholt
Copy link

osholt commented Oct 25, 2021

Has happened to me too, three times now! I thought I was going mad!

@debMan
Copy link

debMan commented Oct 25, 2021

A quick fix:

Consider deleting the lines 46 and 57:

deleteEntries("A")

deleteEntries("AAAA")

    if ipv4_enabled:
        try:
            a = requests.get("https://1.1.1.1/cdn-cgi/trace").text.split("\n")
            a.pop()
            a = dict(s.split("=") for s in a)["ip"]
        except Exception:
            global shown_ipv4_warning
            if not shown_ipv4_warning:
                shown_ipv4_warning = True
                print("🧩 IPv4 not detected")
-            deleteEntries("A")
    if ipv6_enabled:
        try:
            aaaa = requests.get("https://[2606:4700:4700::1111]/cdn-cgi/trace").text.split("\n")
            aaaa.pop()
            aaaa = dict(s.split("=") for s in aaaa)["ip"]
        except Exception:
            global shown_ipv6_warning
            if not shown_ipv6_warning:
                shown_ipv6_warning = True
                print("🧩 IPv6 not detected")
-            deleteEntries("AAAA")

@asheroto
Copy link

asheroto commented Oct 28, 2021

Same here. Thankfully my monitor kicked in and alerted me - it deletes the A record for my root domain, not my subdomain!

Audit log of Cloudflare shows it was the API

@asheroto
Copy link

registry.gitlab.com/kikkia/cloudflare-ddns

Thank you, using this for now :-)

@mendhak
Copy link

mendhak commented Oct 29, 2021

Just got hit by this, I lost my root domain records. 😢

cloudflare-ddns    | 2021-10-29T01:22:03.247134081Z 🧩 IPv4 not detected
cloudflare-ddns    | 2021-10-29T01:22:08.121012339Z 🗑️ Deleted stale record 527a13178ebe61eec4e8xxxxxxx
cloudflare-ddns    | 2021-10-29T01:22:09.237220819Z 🗑️ Deleted stale record 367cf05cd8f9e3323b2f13xxxxxx
cloudflare-ddns    | 2021-10-29T01:22:10.362698135Z 🗑️ Deleted stale record fc9a275ab1fe17f38d8abaxxxxxx
cloudflare-ddns    | 2021-10-29T01:22:11.983824424Z 🗑️ Deleted stale record a88c0318557cb36ab81xxxxxx
cloudflare-ddns    | 2021-10-29T01:22:16.897925571Z 🗑️ Deleted stale record 1ca9750837f94a18131xxxxxx

@timothymiller this can be pretty dangerous, would appreciate some attention on this 🙏

@mendhak
Copy link

mendhak commented Oct 29, 2021

Any ideas where I can see what was deleted and restore it? I don't see any audit logs option in my Cloudflare DNS dashboard. Am I SoL?

@anthonydiiorio
Copy link

Any ideas where I can see what was deleted and restore it? I don't see any audit logs option in my Cloudflare DNS dashboard. Am I SoL?

https://dash.cloudflare.com/ click Audit Log in the navigation

@mendhak
Copy link

mendhak commented Oct 29, 2021

Ah it's at the top level, I wasn't seeing it in my panic-vision. Thank you so much @anthonydiiorio

@aaron2198
Copy link

Same thing happened to me as well, deleted all a records.

@timothymiller
Copy link
Owner

This has been fixed in PR #57

Repository owner deleted a comment from mendhak Oct 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests