DNS Record Types
A, AAAA, CNAME, MX, TXT, NS with worked examples.
Learning objectives
- Choose the correct record type for common tasks
- Read a zone file snippet and explain each line
- Avoid CNAME conflicts at the apex
Records are rows in the phone book
Each DNS record is a row: name, type, value, and TTL (time to live). Here is Workshop Co.’s starter zone:
; Workshop Co. — example zone (simplified)
@ 3600 IN NS ns1.swifthost.ca.
@ 3600 IN NS ns2.swifthost.ca.
@ 3600 IN A 203.0.113.10
www 3600 IN CNAME workshopco.ca.
@ 3600 IN MX 10 mail.workshopco.ca.
mail 3600 IN A 203.0.113.20
@ 3600 IN TXT "v=spf1 include:_spf.google.com ~all"
@ means the apex domain (workshopco.ca itself).
Record types you must know
A
Hostname → IPv4 address
www → 203.0.113.10
AAAA
Hostname → IPv6 address
www → 2001:db8::10
CNAME
Alias → another hostname
www → workshopco.ca.
MX
Mail for domain → mail server hostname + priority
10 mail.workshopco.ca.
TXT
Free-form text — SPF, DKIM, verification
"v=spf1 ..."
NS
Which nameservers are authoritative
ns1.swifthost.ca.
- A CNAME cannot coexist with other records on the same name.
- Many DNS hosts do not allow CNAME at the apex (
@) — use A/AAAA or ALIAS/ANAME if offered. - MX targets must be hostnames with A/AAAA records, not raw IPs.
Worked example — point www to a host
Workshop Co. hosts their site at IP 203.0.113.10. Two valid approaches:
| Approach | Records | When to use |
|---|---|---|
| Direct A record | www A 203.0.113.10 |
Simple, one IP, easy to understand |
| CNAME to apex | www CNAME workshopco.ca.@ A 203.0.113.10 |
Change apex IP once; www follows |
Try it yourself — build a mini zone
Workshop Co. adds a booking app at book.workshopco.ca on IP 203.0.113.15. Write the DNS records (name, type, value) you would add.
Answer
book.workshopco.ca. 3600 IN A 203.0.113.15
Or if the host gives you a hostname: book CNAME app-host.provider.net.
Spot the mistake
Someone added these records for shop.workshopco.ca:
shop CNAME shops.myplatform.com.
shop TXT "verified"
Why might this fail?
Answer
CNAME and TXT on the same name shop violate the CNAME exclusivity rule. Move verification to a different name (e.g. _verify.shop) or use A record instead of CNAME.
Quick quiz
- Which record type do you use so email to
hello@workshopco.cais delivered? - Can an MX record point directly to
203.0.113.20?
Answers
- MX — pointing to a mail server hostname.
- No — MX values must be hostnames. Create
mail A 203.0.113.20and@ MX 10 mail.workshopco.ca.