mjl- / mox

modern full-featured open source secure mail server for low-maintenance self-hosted email
https://www.xmox.nl
MIT License
3.54k stars 100 forks source link

Feature request: support for domain connect #193

Open mdavids opened 2 months ago

mdavids commented 2 months ago

A thing referred to as 'domain connect' exists:

https://datatracker.ietf.org/doc/draft-kowalik-regext-domainconnect/

What this does it automating the update of DNS records at DNS operators that support this.

Whether or not this is the case, can be discovered by checking for a TXT record _domainconnect, for example:

dig +short TXT _domainconnect.example.nl
"api.cloudflare.com/client/v4/dns/domainconnect"

I don't know how hard it is to implement support for this in Mox, but I could imagine it would be a great feature to have.

mjl- commented 1 month ago

Thanks, this indeed looks interesting. It was mentioned here too: https://github.com/mjl-/mox/issues/126#issuecomment-2228134348

I read through the domainconnect I-D again. Some new notes:

It says the synchronous flow (where you make a one-time DNS change) is more commonly supported than the asynchronous flow (where we could make DNS changes at a later time again). The flow is web-based. Based on that, domainconnect may especially help with the initial setup of mox (at least when mox gets a web-based guided setup), less easily with key rotations.

I'm still a bit suspicious of the central database of service templates, and that we would have to get each dns operator to use ours. Would be good to hear about experiences from developers about that, especially those developing self-hosted software, i.e. not a centralized online service. Signing requests seem recommended (for security), with a public key in the template. But on first look, that seems to assume a service provider that can keep the corresponding private key secret. If that's the case, it wouldn't work for software everyone runs themselves.

I find it surprising that the domainconnect I-D doesn't mention DNS updates (rfc2136), and doesn't mention DNS propagation time considerations, or DNS record rotation considerations (e.g. for DKIM keys, or DANE; it does have a section on merging SPF records, so DNS records for email were at least considered).

Next steps could be to do some prototyping:

In other news: I prototyped some code for automated DKIM key rotations, changing DNS records with DNS dynamic updates (rfc2136) and checking/verifying them with AXFR/IXFR, taking propagation times into account (zone negative cache TTL and record TTL). No problems encountered. Still seems like a reasonable approach, at least for my own use case. It will allow for making more kinds of changes from the admin UI/cli (i.e. one click/command to enable acme account binding). The problem of course is that DNS operators don't offer access with those standard protocols. But writing a simple DNS updates/[ia]xfr proxy (that uses an existing Go library (I found multiple candidates) to get/set records through cloud API's) should solve that problem.

mdavids commented 1 month ago

Thank you for the reply. Indeed I was thinking about using domainconnect primarily for the initial setup of Mox.

With regard to the 'in other news';

I recently came across this project. It is, among other things, a pretty impressive, but simple authoritative name server that can even do DNSSEC signing on the fly.

Ant it made me wonder; why not extend Mox with such a server for the DNS records that need to change regularly ? The Go-code of the above project can be used as a great starting point for that.