The DNS database stores various types of Resource Records (RR), each serving a specific purpose. Here are the most commonly asked DNS record types in interviews.
Core Record Types Explained
1. A Record (Address Record)
Function: Maps domain names to IPv4 addresses
Format:
dnswww.example.com. 3600 IN A 192.0.2.1
Use Cases:
- Website server pointing
- Most commonly used DNS record type
- Multiple A records possible for load balancing
2. AAAA Record (IPv6 Address Record)
Function: Maps domain names to IPv6 addresses
Format:
dnswww.example.com. 3600 IN AAAA 2001:db8::1
Use Cases:
- Domain resolution in IPv6 network environments
- Coexists with A records for dual-stack networking
3. CNAME Record (Canonical Name Record)
Function: Creates domain aliases pointing to another domain name
Format:
dnsblog.example.com. 3600 IN CNAME example.github.io.
Important Limitations:
- CNAME records cannot coexist with MX, NS, SOA, or other records on the same domain
- Root domain (@) typically cannot use CNAME
- Introduces additional DNS query latency
Use Cases:
- CDN configuration
- Third-party service integration (like GitHub Pages, Heroku)
- Subdomain unified management
4. MX Record (Mail Exchange Record)
Function: Specifies mail server addresses and priorities
Format:
dnsexample.com. 3600 IN MX 10 mail1.example.com. example.com. 3600 IN MX 20 mail2.example.com.
Priority Explanation:
- Lower numbers indicate higher priority
- Email is sent to servers with lower priority numbers first
- Supports mail server redundancy and load balancing
Use Cases:
- Enterprise email configuration
- Mail service migration
5. NS Record (Name Server Record)
Function: Specifies the authoritative DNS servers for the domain
Format:
dnsexample.com. 86400 IN NS ns1.example.com. example.com. 86400 IN NS ns2.example.com.
Use Cases:
- Domain hosting configuration
- DNS provider switching
- Subdomain delegation
6. TXT Record (Text Record)
Function: Stores arbitrary text information
Format:
dnsexample.com. 3600 IN TXT "v=spf1 include:_spf.google.com ~all"
Common Uses:
- SPF Records: Sender Policy Framework, prevents email spoofing
- DKIM Records: Email digital signature verification
- DMARC Records: Email authentication, reporting, and conformance
- Domain Verification: Google, Baidu, and other search engine verification
7. SOA Record (Start of Authority Record)
Function: Defines zone administration information; each zone file must have exactly one SOA record
Format:
dnsexample.com. 86400 IN SOA ns1.example.com. admin.example.com. ( 2024010101 ; Serial 3600 ; Refresh 1800 ; Retry 604800 ; Expire 86400 ) ; Minimum TTL
Field Descriptions:
| Field | Description |
|---|---|
| Serial | Zone file version number, must increment on changes |
| Refresh | Slave server refresh interval |
| Retry | Retry interval after refresh failure |
| Expire | Slave server data expiration time |
| Minimum TTL | Negative cache TTL |
8. PTR Record (Pointer Record)
Function: Enables reverse DNS resolution, mapping IP addresses to domain names
Format:
dns1.2.0.192.in-addr.arpa. 3600 IN PTR www.example.com.
Use Cases:
- Mail server anti-spam verification
- Network troubleshooting
- Security auditing
9. SRV Record (Service Record)
Function: Defines server locations for specific services
Format:
dns_sip._tcp.example.com. 3600 IN SRV 10 5 5060 sipserver.example.com.
Field Descriptions:
- Priority, weight, port, target server
Use Cases:
- SIP protocol (VoIP)
- XMPP instant messaging
- LDAP service discovery
10. CAA Record (Certification Authority Authorization)
Function: Specifies which Certificate Authorities (CA) can issue certificates for the domain
Format:
dnsexample.com. 3600 IN CAA 0 issue "letsencrypt.org" example.com. 3600 IN CAA 0 issuewild ";"
Use Cases:
- Enhances SSL/TLS certificate security
- Prevents unauthorized certificate issuance
Record Type Comparison Table
| Record Type | Primary Function | Common Usage | Interview Frequency |
|---|---|---|---|
| A | IPv4 address mapping | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ |
| AAAA | IPv6 address mapping | ⭐⭐⭐ | ⭐⭐⭐ |
| CNAME | Domain alias | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ |
| MX | Mail server | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ |
| NS | Name server | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ |
| TXT | Text information | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ |
| SOA | Zone management | ⭐⭐⭐ | ⭐⭐⭐ |
| PTR | Reverse resolution | ⭐⭐⭐ | ⭐⭐⭐ |
| SRV | Service location | ⭐⭐ | ⭐⭐ |
| CAA | CA authorization | ⭐⭐ | ⭐⭐ |
Common Interview Questions
Q: Can A records and CNAME records coexist?
A: No. If a domain has a CNAME record, it cannot have A records or other record types (except DNSSEC-related records).
Q: Why can't root domains use CNAME?
A: Because root domains must have NS and SOA records, and CNAME conflicts with other record types.
Q: For MX records, do lower priority numbers mean higher or lower priority?
A: Lower numbers mean higher priority; email is sent to servers with higher priority first.