DNS resolver
Karta resolves names itself (Karta.DNS, a DNS client in pure Elixir) but
does not recurse: it asks one recursive, DNSSEC-validating resolver,
normally Unbound. Today the
lookups are for outbound delivery: MX records and the A and AAAA records of
mail hosts, and the MTA-STS records of recipient domains and the addresses
of their policy hosts. The client also supports CNAME, PTR, NS, SOA, TLSA
and CAA for the authentication features (SPF, DMARC, DANE).
Configuration
| Variable | Default | Meaning |
|---|---|---|
KARTA_DNS_SERVER | 127.0.0.1 | The resolver's IP address. |
KARTA_DNS_PORT | 53 | Its port. |
KARTA_DNS_TRUST_AD | unset | true: believe the AD bit from a non-loopback address. |
Queries go over UDP with EDNS(0) (a 1232-byte payload) and fall back to TCP when an answer is truncated. Each attempt waits 2 seconds; two UDP attempts are made.
The container image contains no resolver. Run Unbound on the host or as a
sidecar, and point KARTA_DNS_SERVER at it.
Why a local validating resolver
DNSSEC-dependent features (DANE in particular, RFC 7672) must only trust answers that were validated, and Karta does not validate signatures itself: it believes the resolver's AD bit. That is sound only when the resolver validates and nobody can change the traffic between Karta and the resolver. Therefore:
- From a loopback address (
127.0.0.0/8,::1), the AD bit is believed. - From any other address, every answer is treated as not validated,
unless
KARTA_DNS_TRUST_AD=truesays that the path is private, for example a sidecar on a network that nothing else shares.
DANE depends on it: TLSA records are used only from validated answers, for MX hosts from validated answers (Delivery), and REQUIRETLS takes a validated MX answer as proof that the MX host is the domain's. Without a resolver whose AD bit Karta believes, both treat every domain as unsigned: no DANE, and REQUIRETLS mail only to MX hosts an MTA-STS policy names.
Defences against forged answers
Karta.DNS.Resolver.Unbound uses a new socket per attempt with a source port
chosen by the operating system, a random 16-bit query id, and a connected
socket, and it uses an answer only when it comes from the resolver's address
and port, is a response to its query id, and repeats its question exactly.
Everything it decodes has strict bounds.
Cache
Answers are cached in memory per node (Karta.DNS.Cache):
- positive answers for their TTL, but at least 5 seconds and at most one day;
- NXDOMAIN and NODATA answers for the TTL of their SOA record, at most 15 minutes (RFC 2308); a negative answer without an SOA is not cached;
- errors (timeouts, SERVFAIL) never;
- at most 10,000 entries; when full, the entries closest to expiry go first.
Unbound settings
The development stack's dev/unbound/unbound.conf is a test setup with no
upstream (it knows only the test zones); do not copy it for production. A
production Unbound needs, at least, DNSSEC validation with an up-to-date
root trust anchor and access limited to Karta.
What delivery does with the answers
See Delivery, retries and bounces for MX selection, the implicit MX, null MX and blocked address ranges.