Sub topic 4
Resource records: A, AAAA, CNAME, MX, NS, TXT and SOA
This chapter assumes you know what a zone is and how delegation hands parts of the namespace to other servers. You should also be able to run dig in a terminal. Here you will learn what a zone actually contains and how to read and write those contents.
What a resource record is
A zone holds a set of resource records (RRs). Every record has the same five fields:
- Owner name: the name the record is attached to, such as
www.example.com. - TTL: how many seconds a resolver may cache the record.
- Class: almost always
IN(Internet). - Type: what kind of data the record holds, such as
AorMX. - RDATA: the data itself. Its format depends on the type.
Records that share an owner name, class and type form a resource record set (RRset). A resolver caches and returns the set as a unit. If example.com has three A records, all three are returned together, and DNSSEC signs the set as one item. All records in an RRset must have the same TTL.
The zone file
Here is the zone from the chapter plan, which we will use throughout.
$ORIGIN example.com.
$TTL 3600
@ IN SOA ns1.example.com. hostmaster.example.com. (
2026112701 ; serial
7200 ; refresh
3600 ; retry
1209600 ; expire
300 ) ; negative caching TTL
IN NS ns1.example.com.
IN NS ns2.example.com.
IN MX 10 mail.example.com.
IN A 192.0.2.10
IN AAAA 2001:db8::10
www IN CNAME example.com.
mail IN A 192.0.2.25
ns1 IN A 192.0.2.53
ns2 IN A 192.0.2.54Three conventions in the file cause most beginner mistakes:
@stands for the current origin, hereexample.com.- A line that starts with whitespace reuses the previous owner name. The
NS,MX,AandAAAAlines all belong to@. - Names without a trailing dot are relative. The parser appends
$ORIGINto them. Writingmail.example.comwithout the final dot would producemail.example.com.example.com.
Address records: A and AAAA
An A record maps a name to an IPv4 address. An AAAA record (pronounced "quad-A") maps a name to an IPv6 address. They are separate types, so a dual-stack host needs both. Applications ask for both families, as getaddrinfo does, and then choose between the results.
dig +short example.com A
dig +short example.com AAAAA name may have several A records. Resolvers usually rotate the order of the set between responses. This is crude load distribution, and it does not check whether any address is healthy.
CNAME: an alias
A CNAME record says that one name is an alias for another, called the canonical name. In the zone above, www.example.com. is an alias for example.com.. A resolver that receives a CNAME restarts the lookup for the target name and returns the whole chain.
The rules for CNAME records are strict:
- A name with a CNAME can have no other record types. The alias replaces everything at that name. This rule is why you cannot put a
CNAMEat the zone apex: the apex must already holdSOAandNSrecords. - Don't point
MXorNSrecords at an alias. Both must name a host that has address records directly. - Long chains add latency. Each hop is another lookup if it isn't cached.
Some DNS providers offer "ALIAS" or "ANAME" records for the apex. These are not real DNS types. The provider's server resolves the target itself and answers with ordinary A and AAAA records.
MX: where mail goes
An MX record names a mail server for a domain, plus a preference number. Senders try the lowest number first. The record IN MX 10 mail.example.com. means "deliver mail for example.com to the host mail.example.com., preference 10."
dig +noall +answer example.com MXAdding IN MX 20 backup.example.com. creates a fallback. Equal preferences share the load. The target must be a hostname, never an IP address, and that hostname needs its own A or AAAA record. In the zone above, mail has one. If a domain has no MX record, senders fall back to the domain's own address records. A domain that should not receive mail can publish a "null MX" (IN MX 0 .) to say so explicitly.
NS: who is authoritative
An NS record names a server that is authoritative for a zone. The NS set at the apex lists the zone's own servers. The same names also appear in the parent zone as the delegation, which is how resolvers find the zone from the top down.
If a name server lives inside the zone it serves, like ns1.example.com above, resolvers face a circular dependency. The parent zone therefore also stores glue records, which are A and AAAA records for the name servers. You register glue at your registrar, not in your own zone. A mismatch between the parent's NS set and your zone's NS set is a common cause of intermittent failures.
TXT: text with a purpose
A TXT record holds one or more quoted strings. Each string is at most 255 bytes, and longer values are split into several strings that the reader joins together. The type has no built-in meaning. Other systems build conventions on top of it:
| Use | Example owner name | Typical content |
|---|---|---|
| SPF (which servers may send mail) | `example.com.` | `"v=spf1 mx -all"` |
| DKIM (mail signing key) | `sel1._domainkey.example.com.` | `"v=DKIM1; k=rsa; p=..."` |
| DMARC (mail policy) | `_dmarc.example.com.` | `"v=DMARC1; p=quarantine"` |
| Domain ownership proof | `example.com.` | `"site-verification=abc123"` |
Several TXT records can share one name, so a site can carry an SPF record and a verification token side by side. Receivers pick the record they recognize by its prefix.
SOA: the zone's header
Every zone has exactly one SOA (start of authority) record, at the apex. Its RDATA has seven fields:
| Field | Value above | Meaning |
|---|---|---|
| MNAME | `ns1.example.com.` | Primary server for the zone |
| RNAME | `hostmaster.example.com.` | Admin email, with the first `.` standing for `@` |
| Serial | `2026112701` | Version number. Secondary servers compare it to detect changes. |
| Refresh | `7200` | How often secondaries check the primary for a new serial |
| Retry | `3600` | How long to wait before retrying a failed refresh |
| Expire | `1209600` | When a secondary stops answering if it cannot reach the primary |
| Minimum | `300` | Negative caching TTL, per RFC 2308 |
The serial must increase on every change. A common scheme is YYYYMMDDnn, as in 2026112701, meaning the first revision on 27 November 2026. If you edit a zone but forget to raise the serial, secondary servers keep serving the old data.
The last field is easy to misread. In older documents it was called "minimum TTL". Today it only controls how long resolvers cache "this name or type does not exist" answers. Those answers come from the SOA record's TTL and this field, whichever is smaller.
Reading records with dig
The command dig +noall +answer prints just the answer records, one per line, in the owner, TTL, class, type, RDATA layout:
dig +noall +answer www.example.com Awww.example.com. 3600 IN CNAME example.com.
example.com. 3600 IN A 192.0.2.10Here the alias and its target both appear in one answer. When you query a resolver rather than an authoritative server, the TTL counts down as the cached entry ages.
Common mistakes
- Forgetting the trailing dot, which produces doubled names.
- Placing a
CNAMEbeside other records at the same name, such asMXorTXTat an alias. - Pointing
MXat an IP address or at an alias. - Not raising the
SOAserial after an edit. - Leaving a record's
NSset at the registrar different from the one in the zone.
Exercise
A teammate adds mail.example.com. IN CNAME server7.example.net. and then sets example.com. IN MX 10 mail.example.com.. Name the rule this breaks and describe a safer setup.
Show answer
An MX target must be a host with its own address records, not an alias. Some mail servers reject or mishandle an MX that points at a CNAME. The safer setup is to give mail.example.com. direct A and AAAA records, or to point the MX straight at a name that has them.
Exercise
You change www in a zone file but forget to raise the SOA serial. The primary server answers with the new data, and a secondary still returns the old data. Why?
Show answer
Secondaries compare the primary's serial with their own, and they only transfer the zone when the primary's serial is higher. With an unchanged serial, they conclude nothing has changed and keep serving their old copy until the serial increases.
Exercise
The SOA minimum field is 300 and a resolver asks for a name that does not exist. Roughly how long may the resolver cache the "does not exist" answer, assuming the SOA record's own TTL is 3600?
Show answer
About 300 seconds. The negative caching TTL is the smaller of the SOA record's TTL (3600) and the SOA minimum field (300).