“I wanted to point example.com itself at a CDN, so I wrote a CNAME and got an error.”
“I added an MX record, but email does not arrive.”
Both of these are troubles you can prevent by knowing the rules of resource records. The latter is often caused by a single character: the trailing dot.
In Part 4 we looked at the “container” of a DNS message. In Parts 5 and 6 we look at what goes inside it, the resource records. In this first part, we cover how to write a zone file and the SOA, NS, A/AAAA, and CNAME records that form the skeleton of a zone. The records related to email and certificates come in the second part.
▶ This part is also available as a YouTube video (about 17 min) (it is also embedded at the end of this article).
- How to write a zone file
- Relative names and the trailing-dot pitfall
- SOA: the “cover page” of the zone
- NS: the zone’s authoritative DNS servers
- A and AAAA: the DNS round robin misunderstanding
- CNAME restrictions
- Pointing the apex at another name: ALIAS, ANAME, and Route 53 alias
- Wildcards
- Think about it
- Summary
- Watch the video
- The DNS Fundamentals series (12 parts)
How to write a zone file
First, how to write the zone file used by BIND and others. Cloud DNS services such as Route 53 also use it as an import and export format, so it pays to be able to read it.
$ORIGIN example.com.
$TTL 3600
@ IN SOA ns1.example.com. hostmaster.example.com. (
2026092501 ; serial
3600 900 1209600 900 )
IN NS ns1.example.com.
IN NS ns2.example.com.
IN MX 10 mail.example.com.
@ 300 IN A 192.0.2.10
www IN CNAME example.com.
ns1 IN A 192.0.2.53
ns2 IN A 198.51.100.53
mail IN A 192.0.2.25

The rules for reading it are as follows.
- One line is one record: name, TTL, class (IN), type, and value, in that order. If the TTL is omitted, the value of
$TTLis used - $ORIGIN: the domain name appended to relative names. @ means $ORIGIN itself (the zone apex)
- A line whose name field starts with a space uses the same name as the previous line (the NS and MX above belong to @)
- From ; to the end of the line is a comment.
( )lets you split one record across multiple lines
The third rule needs care. Accidents happen in which a space you typed as indentation to make things readable changes the name.
Relative names and the trailing-dot pitfall
The “trailing dot” we touched on in Part 2 matters especially in zone files. A name without a trailing dot is treated as a relative name with $ORIGIN appended.
| Value as written ($ORIGIN example.com.) | Name it is interpreted as | Verdict |
|---|---|---|
| www | www.example.com. | Correct (relative name) |
| www.example.com. | www.example.com. | Correct (FQDN) |
| @ | example.com. | Correct (apex) |
| www.example.com (no dot) | www.example.com.example.com. | Wrong |
| MX 10 mail.example.com (no dot) | mail.example.com.example.com. | Wrong (email does not arrive) |
| CNAME cdn.example.net (no dot) | cdn.example.net.example.com. | Wrong (cannot be resolved) |
What makes it nasty is that it is syntactically valid, so a forgotten dot often causes no error. The “I added an MX but email does not arrive” at the start is very often exactly this forgotten dot.
Verify in two stages: check that the file loads with named-checkzone before applying it, and confirm the actual values with dig after applying it.
$ named-checkzone example.com /var/named/example.com.zone
zone example.com/IN: loaded serial 2026092501
OK
SOA: the “cover page” of the zone
The SOA (Start Of Authority) is the management information for the whole zone, and exactly one must be placed at the zone apex.
| Field | Meaning | Typical value |
|---|---|---|
| MNAME | Name of the primary authoritative DNS server | ns1.example.com. |
| RNAME | The administrator’s email address (@ replaced with .) | hostmaster.example.com. |
| SERIAL | The version number of the zone. A transfer happens only when it increases | YYYYMMDDnn (Part 7) |
| REFRESH | How often the secondary checks for updates | 3600 to 86400 seconds (can be longer if you use NOTIFY) |
| RETRY | How often to retry when a check fails | 600 to 3600 seconds (shorter than REFRESH) |
| EXPIRE | How long the secondary keeps the zone while unable to update before discarding it | 1209600 to 2419200 seconds (2 to 4 weeks, RFC 1912) |
| MINIMUM | The TTL for negative caching | 300 to 3600 seconds (RFC 2308 gives 1 to 3 hours as an example) |
REFRESH, RETRY, and EXPIRE are the three timers that govern the secondary’s behavior.

There are two points to watch.
- The meaning of MINIMUM has changed: In RFC 1035 it was the default TTL, but RFC 2308 changed its meaning to the TTL for negative caching (Part 3). If you reuse the 86400 from an old procedure document as is, you get “I added it but it cannot be resolved for a whole day.”
- Do not make EXPIRE too short: If it is too short, the secondary stops answering during a long holiday when the primary is down.
NS: the zone’s authoritative DNS servers
An NS (Name Server) record indicates the authoritative DNS servers of a zone. As we saw in Part 2, NS records appear in two places.
- The NS records placed in the parent zone, for delegation
- The NS records placed at the apex of your own zone

Keep the contents of the two consistent. A state in which they do not match, or in which a server named in an NS does not answer for the zone, is called a lame delegation, and is a classic cause of intermittent name resolution failures. Which NS a caching DNS server picks changes each time, so the symptom is “it cannot be resolved once in a while.”
Keep the NS rules in mind too.
- The value is a host name that can be resolved by an A/AAAA record
- You cannot write an IP address directly, and writing the name of a CNAME is prohibited (RFC 2181)
- When the NS host name is inside your own zone, glue records are needed in the parent zone
- For availability, run at least two authoritative DNS servers and place them on different networks and at different sites (RFC 2182)
Key points
• Make the delegation NS in the parent match the apex NS in the child
• The value is a host name resolvable through A/AAAA. IP addresses and CNAMEs are not allowed
• Use two or more servers, on different networks and at different sites
A and AAAA: the DNS round robin misunderstanding
An A record maps a name to an IPv4 address, and an AAAA record maps it to an IPv6 address. They are the most basic records. (Remember it as: four A’s for 128 bits.)
You can place multiple A/AAAA records on one name, and using this for load balancing is called DNS round robin.

But a big misunderstanding lurks here.
- Which address is used is up to the client’s implementation, and it does not necessarily follow the order
- Current operating systems and browsers use Happy Eyeballs (RFC 8305), which tries several addresses in parallel, so the order matters even less
- DNS has no health checks and keeps returning the address of a server that has stopped
In short, do not treat DNS round robin as an availability measure. If one server goes down, DNS keeps returning its address. To remove a stopped server, use a load balancer or a DNS service with health checks (such as Route 53 failover in Part 10).
On the other hand, it is fine for different names to point to the same IP address. That is the normal way to write it when one machine has several roles.
CNAME restrictions
A CNAME (Canonical NAME) is a record that makes a name an alias of another name. It is widely used as the official procedure for pointing your own domain at a CDN or SaaS, but there are restrictions you must follow.

1. No other records can be placed at a name that has a CNAME (RFC 1034; DNSSEC signatures and the like are excepted)
The zone apex always has SOA and NS, so you cannot put a CNAME on example.com itself. This is the “I wrote a CNAME at the apex and got an error” from the beginning.
2. The value of MX, NS, and SRV must not be the name of a CNAME (RFC 2181 and others)
3. You cannot place multiple CNAMEs on one name
If you write two thinking of load balancing, it is not defined which one gets used.
Avoid CNAME chains, where the target of a CNAME is another CNAME, because they are slow and add more causes of failure. Do not forget the trailing dot on the value either. It helps to remember that a CNAME replaces everything at that name with another name, which makes the rules easy to recall.
Key points
• A CNAME cannot coexist with other records. It cannot be placed at the apex
• Do not use the name of a CNAME as the value of MX, NS, or SRV
• One CNAME per name. Avoid chains
Pointing the apex at another name: ALIAS, ANAME, and Route 53 alias
So what should you do when you want to point example.com itself at a cloud load balancer or CDN?

| Method | How it works | Can it be placed at the apex? | Notes |
|---|---|---|---|
| CNAME | Returns an alias, and the resolver resolves the rest | No | The standard mechanism. Works on any DNS |
| Route 53 alias | Route 53 directly returns the IP addresses of an ALB, CloudFront, and so on as A/AAAA | Yes | Queries to AWS resources are free of charge. You cannot specify a TTL |
| ALIAS / ANAME, CNAME flattening | The authoritative DNS resolves the name behind the scenes and returns the result as A/AAAA | Yes | A proprietary feature of each DNS provider. Not standardized |
| HTTPS record (AliasMode) | Points from the apex to another name using a standard mechanism | Yes | Used only by clients that support it (Part 6) |
In other words, at the apex, use a mechanism that answers with addresses, not names.
$ dig example.com A +short # Example: pointed at an ALB with a Route 53 alias
192.0.2.80
192.0.2.81
PS> (Resolve-DnsName example.com -Type A).IPAddress # PowerShell, value only
A Route 53 alias looks like an ordinary A record in dig, and you can tell it is an alias only from the Route 53 console or API. Because it is a proprietary feature, check that the same feature exists when you move to another DNS provider (Part 10).
Wildcards
Finally, wildcards.
*.example.com. 3600 IN A 192.0.2.10
www.example.com. 3600 IN A 192.0.2.20

- For a query about a nonexistent name such as
abc.example.comora.b.example.com, an answer is synthesized from the*record (192.0.2.10) - It does not apply to an existing name: if you ask for the MX of
www.example.com, the wildcard is not used and the result is NODATA.x.www.example.comis also NXDOMAIN (RFC 4592) - It does not apply to
example.com(the apex itself). Note also that the rule differs from a wildcard certificate*.example.com, which covers just one level
Convenient as it is, it has drawbacks too.
- Even mistyped names resolve, so configuration errors are hard to notice. Combined with a search domain (Part 3), unintended names can end up being resolved
- A wildcard CNAME pointing to an external service can become an entry point for subdomain takeover (Part 9). Keep its scope to a minimum
Think about it
- If you want to point your organization’s own domain name itself (for example, example.com) at a cloud load balancer or CDN, what options are there? Also think about the impact when you change DNS providers.
- In an operation where zone files are edited by hand, what checking steps should you introduce to prevent forgotten-dot and stray-space accidents?
- How many authoritative DNS servers does your organization have, and where is each one located? Do they match the NS in the parent zone?
Hint: “Pointing the apex at another name,” “Relative names and the trailing-dot pitfall,” and “NS” in this article are your clues.
Summary
- A zone file is one record per line. A line that starts with a space has the same name as the previous line
- A forgotten trailing dot causes no error. Check in two stages with named-checkzone and dig
- The SOA MINIMUM is the TTL for negative caching. Do not make EXPIRE too short
- Make NS match between parent and child and use two or more servers in different places. If they drift apart, you get a lame delegation
- DNS round robin is not an availability measure
- A CNAME cannot be placed at the apex. Point the apex using a Route 53 alias or ALIAS
Next time (part 2), we cover email (MX, SPF, DKIM, DMARC), SRV and PTR, certificates (CAA), and the newer HTTPS/SVCB records.
Watch the video
This part is also explained in a YouTube video (about 17 min).
All parts of the series are in the DNS Fundamentals playlist on YouTube.
The DNS Fundamentals series (12 parts)
All 12 parts with a reading guide: DNS Fundamentals
- What Is DNS? How Name Resolution Works and Its Three Key Players
- The domain name hierarchy and delegation
- How name resolution works
- DNS messages and transport
- Resource records, part 1 (this article)
- Resource records, part 2
- Running authoritative DNS servers
- Investigating with commands
- DNS security
- DNS in the cloud and on corporate networks
- DNS troubleshooting
- DNS design exercises
This series is the English edition of 【DNS入門】, originally written in Japanese.


コメント