DNS Record Types – Complete Reference Guide
1. What Is a DNS Record?
A DNS record is an entry in a DNS zone file — the authoritative database for
a domain — that maps a hostname to data of a specific type. When a DNS resolver
queries for www.example.com, the authoritative nameserver returns the
relevant record(s) from its zone file.
Every DNS record follows the same basic structure:
; DNS Zone File Record Format: ; <name> <TTL> <class> <type> <rdata> example.com. 3600 IN A 93.184.216.34 www 300 IN CNAME example.com. example.com. 3600 IN MX 10 mail.example.com. ; name = the hostname or domain this record applies to ; "@" means the apex (root) of the zone itself ; TTL = Time To Live in seconds — how long resolvers cache this answer ; class = always IN (Internet) for modern DNS ; type = the record type (A, MX, TXT, etc.) ; rdata = the record data — varies by type
example.com.) is a fully qualified domain name (FQDN) — absolute.
A name without a trailing dot (www) is relative and the zone's
origin is appended automatically, making it www.example.com.
Related pages: How DNS Works | How DHCP Works | DHCP Overview | IPv6 | Common Port Numbers | NTP Synchronisation | Troubleshooting Methodology
2. Quick Reference — All DNS Record Types
| Type | Full Name | Purpose | dig Command |
|---|---|---|---|
| A | Address | Maps hostname → IPv4 address | dig example.com A |
| AAAA | IPv6 Address | Maps hostname → IPv6 address | dig example.com AAAA |
| CNAME | Canonical Name | Alias — maps one hostname to another hostname | dig www.example.com CNAME |
| MX | Mail Exchange | Specifies mail servers for a domain with priority | dig example.com MX |
| TXT | Text | Arbitrary text — SPF, DKIM, DMARC, site verification | dig example.com TXT |
| NS | Name Server | Delegates a zone to authoritative nameservers | dig example.com NS |
| PTR | Pointer | Reverse DNS — maps IP address → hostname | dig -x 93.184.216.34 |
| SOA | Start of Authority | Zone metadata — primary NS, serial, refresh/retry timers | dig example.com SOA |
| SRV | Service Locator | Locates services by protocol and port (SIP, XMPP, AD) | dig _sip._tcp.example.com SRV |
| CAA | Certification Authority Authorisation | Restricts which CAs can issue SSL/TLS certificates | dig example.com CAA |
| DNSKEY | DNS Key | DNSSEC public key for signature verification | dig example.com DNSKEY |
| RRSIG | Resource Record Signature | DNSSEC cryptographic signature over a record set | dig example.com A +dnssec |
| DS | Delegation Signer | DNSSEC chain of trust from parent to child zone | dig example.com DS |
| NAPTR | Name Authority Pointer | Used in VoIP (SIP/ENUM) for phone number mapping | dig example.com NAPTR |
| ANY | All types | Request all record types (many servers restrict this) | dig example.com ANY |
3. A Record — IPv4 Address Mapping
The A record (Address record) is the most fundamental DNS record type. It maps a fully qualified domain name to a 32-bit IPv4 address, enabling clients to find the IP of any named internet service.
; Zone file syntax: ; <name> TTL IN A <IPv4 address> example.com. 3600 IN A 93.184.216.34 www.example.com. 300 IN A 93.184.216.34 mail.example.com. 3600 IN A 93.184.216.40 api.example.com. 60 IN A 93.184.216.50 ; Multiple A records for the same name = round-robin load balancing google.com. 60 IN A 142.250.183.14 google.com. 60 IN A 142.250.183.46 google.com. 60 IN A 142.250.183.78
! Query with dig: $ dig example.com A ! or just: dig example.com ;; ANSWER SECTION: example.com. 3600 IN A 93.184.216.34 ! Query with nslookup: C:\> nslookup example.com Name: example.com Address: 93.184.216.34
Key A Record Facts
| Aspect | Detail |
|---|---|
| Address format | Dotted-decimal IPv4: 0.0.0.0 to 255.255.255.255 |
| Multiple records | Multiple A records for the same name create round-robin load distribution. DNS returns all IPs; the client typically uses the first. |
| TTL impact | Short TTL (60s) = fast failover / CDN flexibility. Long TTL (86400s) = low query load but slow propagation on changes. |
| Apex domain | The bare domain (example.com without www) must use an A record directly — cannot use a CNAME at the apex. |
4. AAAA Record — IPv6 Address Mapping
The AAAA record (Quad-A record) maps a hostname to a 128-bit IPv6 address. It is the IPv6 equivalent of the A record. Modern operating systems query for both A and AAAA simultaneously (Happy Eyeballs / RFC 6555) and use whichever responds first, preferring IPv6 when available.
; Zone file syntax: example.com. 3600 IN AAAA 2606:2800:220:1:248:1893:25c8:1946 www.example.com. 300 IN AAAA 2606:2800:220:1:248:1893:25c8:1946 ! Query: $ dig example.com AAAA ;; ANSWER SECTION: example.com. 3598 IN AAAA 2606:2800:220:1:248:1893:25c8:1946
5. CNAME Record — Canonical Name (Alias)
A CNAME record (Canonical Name) creates an alias — it maps one hostname to another hostname rather than directly to an IP address. The resolver follows the chain until it reaches a final A or AAAA record.
; Zone file syntax: ; <alias> TTL IN CNAME <canonical hostname> www.example.com. 300 IN CNAME example.com. ftp.example.com. 300 IN CNAME example.com. blog.example.com. 300 IN CNAME mysite.wordpress.com. ; CDN use case — CNAME points to CDN edge hostname: www.example.com. 300 IN CNAME example.cdn.cloudflare.net. ! Resolution chain: ! www.example.com → CNAME → example.com → A → 93.184.216.34
! dig shows the full chain: $ dig www.example.com ;; ANSWER SECTION: www.example.com. 300 IN CNAME example.com. example.com. 3600 IN A 93.184.216.34
Critical CNAME Restrictions
| Rule | Explanation |
|---|---|
| Cannot exist at the apex domain | You cannot have a CNAME for example.com. (the bare domain
with no subdomain). The apex must use an A or AAAA record directly. Some
DNS providers (Cloudflare, Route 53) offer "CNAME flattening" or "ALIAS"
pseudo-records that resolve this at query time. |
| Cannot coexist with other record types | A name that has a CNAME cannot also have an MX, TXT, or other record.
If www is a CNAME, it cannot also have an MX record. |
| Chains are valid but should be short | CNAME → CNAME → A is valid but each hop adds a DNS lookup. Long chains increase resolution time. Maximum practical depth: 2–3 hops. |
| The target must resolve | A CNAME pointing to a hostname with no A/AAAA record results in NOERROR with an empty ANSWER — the original name resolves but the final target has no IP. |
6. MX Record — Mail Exchange
MX records specify which mail servers accept email for a domain. When an
SMTP server delivers email to [email protected], it first queries DNS
for example.com's MX records, then connects to the returned mail server hostnames.
; Zone file syntax: ; <domain> TTL IN MX <priority> <mail server hostname> example.com. 3600 IN MX 10 mail1.example.com. example.com. 3600 IN MX 20 mail2.example.com. example.com. 3600 IN MX 30 mail3.example.com. ; Each mail server hostname must also have an A record: mail1.example.com. 3600 IN A 93.184.216.40 mail2.example.com. 3600 IN A 93.184.216.41 ; Real-world example — Gmail's MX records: gmail.com. 3599 IN MX 5 gmail-smtp-in.l.google.com. gmail.com. 3599 IN MX 10 alt1.gmail-smtp-in.l.google.com. gmail.com. 3599 IN MX 20 alt2.gmail-smtp-in.l.google.com. gmail.com. 3599 IN MX 30 alt3.gmail-smtp-in.l.google.com. gmail.com. 3599 IN MX 40 alt4.gmail-smtp-in.l.google.com.
MX Priority Rules
| Priority Value | Meaning | Behaviour |
|---|---|---|
| Lower number (e.g., 5) | Higher preference — tried first | Sending servers always attempt the lowest-priority-number server first |
| Higher number (e.g., 40) | Lower preference — fallback only | Only used if all lower-numbered servers are unreachable or return a temporary error (4xx) |
| Equal numbers (e.g., 10 and 10) | Same preference — load balancing | Sending servers randomly select between equal-priority entries, distributing load |
7. TXT Record — Text (SPF, DKIM, DMARC, Verification)
TXT records hold arbitrary text data. Originally designed for human-readable information, they are now critical infrastructure for email authentication, domain ownership verification, and security policies.
; Zone file syntax: ; <name> TTL IN TXT "<text string>" example.com. 3600 IN TXT "v=spf1 include:_spf.google.com ~all" example.com. 3600 IN TXT "google-site-verification=abc123xyz"
TXT Record Use Cases
| Use Case | Format | Purpose |
|---|---|---|
| SPF (Sender Policy Framework) | "v=spf1 include:_spf.google.com ~all" |
Lists IP addresses and servers authorised to send email for the domain. Receiving servers check SPF to verify the sender is legitimate. |
| DKIM (DomainKeys Identified Mail) | selector._domainkey.example.com TXT "v=DKIM1; k=rsa; p=MIGfMA0..." |
Publishes the public key that receiving servers use to verify the cryptographic signature on outgoing emails. Confirms the email body hasn't been modified in transit. |
| DMARC (Domain-based Message Authentication) | _dmarc.example.com TXT "v=DMARC1; p=reject; rua=mailto:[email protected]" |
Defines what to do when SPF/DKIM checks fail: none (monitor), quarantine (spam folder), or reject. Also specifies where to send aggregate reports. |
| Domain verification | "google-site-verification=abc123" |
Google, Microsoft, and other services require adding a specific TXT record to prove you control the domain before granting access to their services. |
| BIMI (Brand Indicators for Message Identification) | default._bimi.example.com TXT "v=BIMI1; l=https://...logo.svg" |
Associates a brand logo with authenticated email — displayed in email clients that support BIMI (Gmail, Apple Mail, Yahoo). |
SPF Mechanisms Reference
; Full SPF TXT record example with common mechanisms: example.com. IN TXT "v=spf1 ip4:203.0.113.0/24 include:_spf.google.com a mx ~all" ; v=spf1 = SPF version — must always be present first ; ip4:x.x.x.x/nn = Authorise specific IPv4 range to send email ; ip6: = Authorise IPv6 range ; include:domain = Also check SPF of this other domain (e.g., your ESP) ; a = Authorise the IP(s) in the domain's A record ; mx = Authorise the IP(s) in the domain's MX records ; ~all = Soft fail — mark as spam if no mechanism matched ; -all = Hard fail — reject if no mechanism matched (strictest) ; ?all = Neutral — no policy (essentially no SPF enforcement)
8. NS Record — Name Server
NS records identify the authoritative nameservers for a domain or zone. They are the delegation mechanism of DNS — the TLD nameservers hold NS records for every registered domain, telling the world which nameservers are authoritative for that domain's DNS zone.
; Zone file syntax: ; <domain> TTL IN NS <nameserver hostname> example.com. 86400 IN NS ns1.example.com. example.com. 86400 IN NS ns2.example.com. ; The NS records are also held at the TLD level (com.) pointing to the same servers: ; This is the delegation — without it, no one can find the zone ; Glue records — A records for the NS hostnames (needed when NS is IN the zone) ; These must be provided to the TLD servers to avoid a circular lookup: ns1.example.com. 86400 IN A 198.51.100.1 ns2.example.com. 86400 IN A 198.51.100.2
ns1.example.com
and you need to look up example.com, you need to know
ns1.example.com's IP first — but that IP is in the example.com
zone, which you can't get without knowing ns1's IP. This circular dependency is
broken by glue records — the parent TLD zone also stores the A records for
the NS hostnames, allowing the chain to resolve.
! Query NS records: $ dig example.com NS ;; ANSWER SECTION: example.com. 86400 IN NS ns1.example.com. example.com. 86400 IN NS ns2.example.com. ;; ADDITIONAL SECTION: ← Glue records ns1.example.com. 86400 IN A 198.51.100.1 ns2.example.com. 86400 IN A 198.51.100.2
9. PTR Record — Pointer (Reverse DNS)
PTR records are the inverse of A records — they map an IP address back to
a hostname. They live in special reverse DNS zones under .in-addr.arpa.
(IPv4) or .ip6.arpa. (IPv6), not in the domain's forward zone.
; PTR records live in the reverse zone, NOT the domain's forward zone ; IPv4 reverse zone: octets reversed + .in-addr.arpa. ; For IP 93.184.216.34 → reverse zone: 216.184.93.in-addr.arpa. ; Zone file for 216.184.93.in-addr.arpa.: 34 86400 IN PTR example.com. ; This means: 93.184.216.34 → example.com ; Real-world examples (Google DNS): 8.8.8.8.in-addr.arpa. 86399 IN PTR dns.google. 8.8.4.4.in-addr.arpa. 21599 IN PTR dns.google.
! Query reverse DNS: $ dig -x 8.8.8.8 ;; QUESTION SECTION: ;8.8.8.8.in-addr.arpa. IN PTR ;; ANSWER SECTION: 8.8.8.8.in-addr.arpa. 86399 IN PTR dns.google.
10. SOA Record — Start of Authority
The SOA record (Start of Authority) is mandatory in every DNS zone. It identifies the primary authoritative nameserver for the zone and contains timing parameters that control how secondary nameservers synchronise with the primary and how resolvers handle negative responses.
; SOA record syntax:
; <zone> TTL IN SOA <primary NS> <admin email> (
; serial
; refresh
; retry
; expire
; negative TTL )
example.com. 3600 IN SOA ns1.example.com. admin.example.com. (
2024041501 ; Serial — zone version number
7200 ; Refresh — how often secondaries check for updates (secs)
3600 ; Retry — how long to wait before retrying failed refresh
1209600 ; Expire — after this many seconds, secondary stops serving
3600 ; Negative TTL — how long to cache NXDOMAIN responses
)
SOA Field Explanations
| Field | Typical Value | Meaning |
|---|---|---|
| Serial | 2024041501 | Zone version number — must be incremented every time the zone is changed. Secondary nameservers compare their serial to the primary; if the primary's serial is higher, they initiate a zone transfer. Common format: YYYYMMDDNN (date + daily change sequence number). |
| Refresh | 7200 (2 hours) | How often (in seconds) secondary nameservers poll the primary to check if the serial has changed. |
| Retry | 3600 (1 hour) | If the secondary's refresh attempt fails (primary unreachable), how long to wait before retrying. |
| Expire | 1209600 (14 days) | If the secondary cannot contact the primary for this long, it stops serving the zone entirely — preventing stale data from being authoritative. |
| Negative TTL | 3600 (1 hour) | How long resolvers cache negative answers (NXDOMAIN responses). Defined in RFC 2308. Prevents repeated queries for non-existent names. |
| Admin email | admin.example.com. | The zone administrator's email address — the first . replaces
the @. So admin.example.com. means
[email protected]. |
11. SRV Record — Service Locator
SRV records allow a domain to publish the location (hostname and port) of specific network services. They are essential for VoIP, instant messaging, Microsoft Active Directory, and other services where clients need to discover the correct server and port programmatically without hardcoding them.
; SRV record syntax: ; _<service>._<protocol>.<domain> TTL IN SRV <priority> <weight> <port> <hostname> ; SIP over TCP: _sip._tcp.example.com. 3600 IN SRV 10 20 5060 sip1.example.com. _sip._tcp.example.com. 3600 IN SRV 20 10 5060 sip2.example.com. ; Microsoft Active Directory (LDAP, Kerberos): _ldap._tcp.example.com. 600 IN SRV 0 100 389 dc1.example.com. _kerberos._tcp.example.com. 600 IN SRV 0 100 88 dc1.example.com. ; XMPP (Jabber instant messaging): _xmpp-client._tcp.example.com. 3600 IN SRV 5 0 5222 xmpp.example.com.
SRV Field Reference
| Field | Description |
|---|---|
| Service | Standardised service name, prefixed with underscore: _sip,
_ldap, _http, _xmpp-client |
| Protocol | _tcp or _udp |
| Priority | Lower value = higher preference (same logic as MX). Clients try lower priority first, fall back on failure. |
| Weight | Load distribution among equal-priority records. Higher weight = more traffic. Weight 0 = no preference. |
| Port | TCP/UDP port number the service listens on. This allows non-standard ports without client configuration. |
| Target | Fully qualified hostname of the server. Must have its own A/AAAA record.
A single dot (.) means the service is not available. |
12. CAA Record — Certification Authority Authorisation
CAA records specify which Certificate Authorities (CAs) are permitted to issue SSL/TLS certificates for a domain. CAs are required (by the CA/Browser Forum) to check for CAA records before issuing a certificate. If a CA is not listed, it must refuse to issue.
; Zone file syntax: ; <domain> TTL IN CAA <flag> <tag> "<value>" ; Allow only Let's Encrypt to issue certificates: example.com. 3600 IN CAA 0 issue "letsencrypt.org" ; Allow Let's Encrypt AND DigiCert: example.com. 3600 IN CAA 0 issue "letsencrypt.org" example.com. 3600 IN CAA 0 issue "digicert.com" ; Allow wildcard certificates from one specific CA: example.com. 3600 IN CAA 0 issuewild "sectigo.com" ; Prohibit all CAs from issuing (no CA listed at all): example.com. 3600 IN CAA 0 issue ";" ; Notification email for policy violations: example.com. 3600 IN CAA 0 iodef "mailto:[email protected]"
dig example.com CAA.
13. DNSSEC Records — DNSKEY, RRSIG, DS, NSEC
DNSSEC (DNS Security Extensions) adds cryptographic authentication to DNS responses, preventing cache poisoning and data tampering. It uses four additional record types that work together as a chain of trust.
| Record Type | Purpose | Where It Lives |
|---|---|---|
| DNSKEY | Publishes the zone's public signing key. Resolvers use this to verify RRSIG signatures. | In the zone being signed |
| RRSIG | A cryptographic signature over a specific record set. Every signed record set has a corresponding RRSIG. | Alongside every signed record in the zone |
| DS (Delegation Signer) | A hash of the child zone's DNSKEY, stored in the parent zone. Creates the chain of trust from parent to child (e.g., .com has DS for example.com). | In the parent zone |
| NSEC / NSEC3 | Authenticated denial of existence — proves that a requested name or type does not exist. Prevents attackers from injecting fake NXDOMAIN responses. NSEC3 adds hashing to prevent zone enumeration. | In the zone being signed |
! Query DNSSEC records: $ dig example.com +dnssec A ;; ANSWER SECTION: example.com. 3600 IN A 93.184.216.34 example.com. 3600 IN RRSIG A 13 2 3600 20241101000000 ... ! The "ad" flag in the header means the resolver validated DNSSEC: ;; flags: qr rd ra ad; ← "ad" = Authenticated Data
14. Common Misconceptions About DNS Records
-
"CNAME and A records do the same thing."
An A record maps directly to an IP address. A CNAME maps to another hostname which must itself be resolved. CNAME adds an extra lookup hop. A records are required at the apex domain — CNAMEs cannot be used there. -
"MX records can point directly to an IP address."
The DNS specification (RFC 2821) requires MX records to point to a hostname, not an IP address. The hostname must have its own A/AAAA record. Similarly, MX records must not point to a CNAME target. -
"Changing a DNS record takes effect immediately."
Changes are instant on the authoritative server but propagate based on the TTL. If the old record had TTL 86400 (24 hours), resolvers that cached it will continue returning the old value for up to 24 hours. Always lower TTL well before planned changes. -
"You need separate TXT records for each email authentication method."
SPF, DKIM, and DMARC are actually stored at different DNS names. SPF is a TXT at the domain apex (example.com). DKIM uses a selector prefix (selector._domainkey.example.com). DMARC uses the_dmarcsubdomain (_dmarc.example.com). They do not conflict with each other. -
"NS records control which server hosts your website."
NS records only delegate DNS authority — they specify which servers are authoritative for your DNS zone. Website hosting is controlled by A/AAAA records. Changing NS records at your registrar transfers DNS management; it does not move your website.
15. Key Points & Exam Tips
- A = hostname → IPv4 (32-bit). AAAA = hostname → IPv6 (128-bit).
- CNAME = alias → another hostname. Cannot exist at apex domain. Cannot coexist with other record types at the same name.
- MX = mail servers + priority. Lower number = higher preference. Must point to a hostname (A record), never an IP or CNAME.
- TXT = arbitrary text. Key uses: SPF (email sender policy), DKIM (email signing keys), DMARC (email policy), domain ownership verification.
- NS = authoritative nameservers for a zone. Present at TLD level (delegation) and in the zone itself. Glue records needed when NS is within the zone.
- PTR = IP → hostname (reverse DNS). Lives in
.in-addr.arpa.(IPv4) or.ip6.arpa.(IPv6) zones. Managed by IP block owner (ISP), not domain owner. - SOA = one per zone. Contains: primary NS, admin email (dot instead of @), serial, refresh, retry, expire, negative TTL.
- SOA serial must be incremented on every zone change for secondary nameservers to detect and sync the update.
- SRV = service discovery by protocol and port. Format:
_service._proto.domain SRV priority weight port hostname. - CAA = restricts which CAs can issue SSL/TLS certs for the domain. CAs must check and respect CAA before issuing.
- DNSSEC records: DNSKEY (public signing key), RRSIG (signature), DS (parent trust anchor), NSEC/NSEC3 (authenticated denial of existence).
- TTL on any record controls how long resolvers cache it — low TTL = fast change propagation, high TTL = less query load.
Related pages: How DNS Works | How DHCP Works | DHCP Overview | IPv6 | Common Port Numbers | NTP Synchronisation | Troubleshooting Methodology