Skip to content

Feature request: option to remove DNS records no longer present in config #291

@M0okz

Description

@M0okz

Hi, and thanks for GoDNS – it’s been rock-solid for keeping a bunch of Cloudflare A records in sync with my public IP 👋

I’ve hit a limitation with how the reconciliation loop currently works:

  • I manage a relatively large number of subdomains on a single zone (dozens of A records).
  • GoDNS does exactly what I expect for create and update:
    • If a subdomain in domains[].sub_domains has no DNS record → it gets created.
    • If the DNS record exists but the IP has changed → it gets updated.
  • However, if I remove a subdomain from sub_domains in config.json, the corresponding DNS record is left behind at the provider (Cloudflare in my case) and is never touched again.

Over time this leads to drift:

  • The config file becomes the “desired state”.
  • The DNS zone accumulates stale/unused records that are no longer referenced anywhere in the config.
  • There’s no way to “garbage collect” DNS records that are not part of the desired state anymore.

Feature proposal

Introduce an optional “config as source of truth” mode where GoDNS:

  • Treats config.json as the desired state for the managed domain(s).
  • On each reconciliation loop:
    1. Lists existing DNS records for the configured domain(s) (A/AAAA only, or configurable).
    2. Compares them against domains[].sub_domains.
    3. Deletes records that:
      • belong to a managed domain,
      • are of a managed type (A and/or AAAA),
      • and are not present in the current sub_domains list.

Something like:

{
  "provider": "Cloudflare",
  "login_token": "",
  "domains": [
    {
      "domain_name": "example.com",
      "sub_domains": ["app", "api", "vpn"]
    }
  ],
  "cleanup_unknown_records": true
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions