乐闻世界logo
搜索文章和话题

What Are the Common DNS Record Types and Their Functions

3月6日 22:50

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:

dns
www.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:

dns
www.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:

dns
blog.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:

dns
example.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:

dns
example.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:

dns
example.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:

dns
example.com. 86400 IN SOA ns1.example.com. admin.example.com. ( 2024010101 ; Serial 3600 ; Refresh 1800 ; Retry 604800 ; Expire 86400 ) ; Minimum TTL

Field Descriptions:

FieldDescription
SerialZone file version number, must increment on changes
RefreshSlave server refresh interval
RetryRetry interval after refresh failure
ExpireSlave server data expiration time
Minimum TTLNegative cache TTL

8. PTR Record (Pointer Record)

Function: Enables reverse DNS resolution, mapping IP addresses to domain names

Format:

dns
1.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:

dns
example.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 TypePrimary FunctionCommon UsageInterview Frequency
AIPv4 address mapping⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
AAAAIPv6 address mapping⭐⭐⭐⭐⭐⭐
CNAMEDomain alias⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
MXMail server⭐⭐⭐⭐⭐⭐⭐⭐
NSName server⭐⭐⭐⭐⭐⭐⭐⭐
TXTText information⭐⭐⭐⭐⭐⭐⭐⭐
SOAZone management⭐⭐⭐⭐⭐⭐
PTRReverse resolution⭐⭐⭐⭐⭐⭐
SRVService location⭐⭐⭐⭐
CAACA 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.

标签:DNS