← First Pair Library

4 Resource records: typed facts with lifetimes

4.1 The common envelope

Every resource record has:

The TTL is a lease offered to caches. If an authoritative server returns a TTL of 300 seconds, a cache may reuse that answer for at most five minutes before refreshing it. The TTL does not schedule a change and does not guarantee that every cache holds the answer for the full interval. It establishes an upper bound.

Changing a record and then lowering its TTL is too late for clients that already cached the older, longer lease. Planned migrations lower the TTL at least one old-TTL interval before the change, wait, make the change, and later raise it.

4.2 Core types

A maps an owner to an IPv4 address. AAAA maps it to an IPv6 address. Several records at one owner form an address RRset; DNS does not promise that clients use them in listed order.

NS names an authoritative server for a zone or delegation.

SOA, the start of authority, identifies the zone and carries operational parameters: primary server, responsible mailbox, serial, refresh, retry, expire, and negative-cache values. A secondary compares serial numbers to decide whether a transfer is needed. Serial arithmetic wraps in a defined 32-bit space, so blindly treating it as an ordinary integer can be wrong near the boundary.

CNAME says that its owner is an alias of another name. Except for DNSSEC and narrowly specified metadata, an owner with CNAME should not also hold unrelated data. A resolver follows the chain while defending against loops and excessive depth.

MX names a mail exchanger and gives it a preference. Lower numbers are preferred. The target is a name, not an address.

PTR provides a name-valued reverse mapping. IPv4 reverse names live below in-addr.arpa. with octets reversed. IPv6 reverse names live below ip6.arpa. with hexadecimal nibbles reversed.

TXT carries one or more length-delimited byte strings. Presentation formats often make it look like one free-form string, but the wire format retains segments.

SRV names a service endpoint with priority, weight, port, and target.

CAA constrains which certification authorities may issue certificates for a domain.

OPT is not ordinary zone data. It is a pseudo-record used by EDNS to negotiate UDP payload size and carry extension flags and options.

rgbdns models these forms with RecordType, Record, and the RData enum in src/packet.rs. Known structured types receive structured variants. Unknown types can remain opaque where the format permits, preserving extensibility without confusing untrusted lengths with trusted objects.

4.3 Additional data is an optimization

If an answer contains MX, NS, or SRV targets, the server may include associated A and AAAA records in the additional section. This can save queries. It does not change which RRset directly answers the question, and a resolver must apply the correct credibility rules rather than trusting unrelated additional data.

The rgbdns authoritative response path collects target names from those record types and adds locally available addresses. It de-duplicates targets before lookup and preserves the distinction between answers and helpful additionals.