mholt / caddy-dynamicdns

Caddy app that keeps your DNS records (A/AAAA) pointed at itself.
Apache License 2.0
250 stars 25 forks source link

dns provider hetzner #60

Open gandalfb opened 9 months ago

gandalfb commented 9 months ago

Currently I am fiddling with Caddy. With this plugin ~3 ddns container could be obsolete.

I tested with dns provider hetzner and experienced that the A records are duplicated rather than updated. Maybe an Option would be possible to disable the creation of records but only update them.

This would mean to add the record manually and the update to happen automatically. And it prevents errournous duplicate entries.

Happy to provide further details. A minimal setup is difficult sadly, as it is only possible with token.

I applied the following ddns details: domain.xyz @ ddns domaein2.xyz @ root

Both domains got processed with 2 entries each, but ended up having duplicates within hetzner dns.

Thanks! Gandalf

francislavoie commented 9 months ago

That's a bug with the hetzner DNS plugin.

Most DNS plugins were only tested with TXT records, so it probably doesn't properly implement the Setter interface to overwrite existing A records, as this app uses.

gandalfb commented 9 months ago

Oh I see there is an option: update_only

Will try this out. Thank you for your response.

Mayber update_only will solve it.

francislavoie commented 9 months ago

No all that does is not create A records if none already exist (i.e. ignore domains missing an A record).

gandalfb commented 9 months ago
    // If enabled, no new DNS records will be created. Only existing records will be updated.
    // This means that the A or AAAA records need to be created manually ahead of time.
    UpdateOnly bool `json:"update_only,omitempty"`

According to code/comment it looks exactly as an option to mitigate duplicates... I have to test it.

gandalfb commented 9 months ago

Screenshot_2024-02-01_11-31-21

Nope, duplication is no stopped with "update_only" either.

    dynamic_dns {
        provider hetzner {env.HETZNER_API_TOKEN}
        domains {
                        domain.xyz @ ddns
        }
        ip_source simple_http https://icanhazip.com
        check_interval 5m
    update_only
        versions ipv4
        ttl 1h
    }

Don't know now if it's a misbehavior of the ddns plugin for maybe "update_only" or the hetzner dns plugin.

Thank you

francislavoie commented 9 months ago

According to code/comment it looks exactly as an option to mitigate duplicates... I have to test it.

No, it says exactly what I said:

This means that the A or AAAA records need to be created manually ahead of time.

This is saying that if there is no A record at all then it will skip creating one, and it will only attempt to modify the A record if there was already one. It does nothing to mitigate duplicates, and doesn't say that at all.

Like for example you only have A foo.example.com 2.3.4.5 but you configured your Caddyfile with bar.example.com, when you enable update_only it will not attempt to add an A record for bar, and it will only touch foo if that's in your Caddyfile because it has an A record.

Again, like I said, I'm pretty sure this is a bug with the hetzner DNS plugin because it was only tested for TXT records with the DNS challenge and not with DDNS. Open an issue on that repo to get help from its maintainer.