DNS records are the instructions that tell the internet how to find your website, deliver your email, and route traffic to the right services. If you manage a domain, you'll work with these records regularly—whether you're pointing a domain to a new server, setting up email, or configuring third-party services.
This guide covers the six DNS record types you'll encounter most often: A, AAAA, CNAME, MX, TXT, and SRV. You'll learn what each record does, when you need it, and how to configure it correctly.
A Records: Pointing Domains to IPv4 Addresses
An A record (Address record) maps a domain or subdomain to an IPv4 address. This is the most fundamental DNS record type—it's how browsers find your web server.
When to Use A Records
- Point your root domain (
example.com) to your server's IP address - Direct subdomains (
blog.example.com,shop.example.com) to specific servers - Create multiple A records for the same hostname to enable simple round-robin load balancing
Configuration Format
example.com. A 203.0.113.10
www.example.com. A 203.0.113.10
blog.example.com. A 198.51.100.25
Each A record consists of:
- Name: the hostname (use @ for the root domain in many DNS interfaces)
- Type: A
- Value: the IPv4 address in dotted-decimal notation
- TTL: how long resolvers should cache the record (often 300-3600 seconds)
Common Use Cases
Root domain and www subdomain: Most sites create two A records pointing to the same IP:
@ A 203.0.113.10
www A 203.0.113.10
Separate servers for different services: You might host your main site on one server and your blog on another:
@ A 203.0.113.10
blog A 198.51.100.25
AAAA Records: The IPv6 Equivalent
An AAAA record (quad-A record) maps a domain to an IPv6 address. It functions exactly like an A record but uses the 128-bit IPv6 address format instead of IPv4's 32-bit format.
When to Use AAAA Records
- Your server has an IPv6 address and you want IPv6 clients to connect directly
- You're preparing for IPv6 adoption while maintaining IPv4 support (dual-stack configuration)
- Your hosting provider or CDN requires IPv6 configuration
Configuration Format
example.com. AAAA 2001:0db8:85a3:0000:0000:8a2e:0370:7334
www.example.com. AAAA 2001:0db8:85a3:0000:0000:8a2e:0370:7334
Dual-Stack Configuration
Most sites should configure both A and AAAA records to support all users:
example.com. A 203.0.113.10
example.com. AAAA 2001:0db8:85a3::8a2e:0370:7334
www.example.com. A 203.0.113.10
www.example.com. AAAA 2001:0db8:85a3::8a2e:0370:7334
Clients with IPv6 connectivity will prefer the AAAA record, while IPv4-only clients will use the A record.
CNAME Records: Creating Aliases
A CNAME record (Canonical Name record) creates an alias from one domain name to another. When a resolver looks up a CNAME, it follows the alias to find the target's A or AAAA record.
When to Use CNAME Records
- Point subdomains to external services (CDNs, email providers, SaaS platforms)
- Maintain a single source of truth when multiple hostnames should resolve to the same destination
- Simplify management when the underlying IP address changes frequently
Configuration Format
www.example.com. CNAME example.com.
shop.example.com. CNAME shops.shopify.com.
Important CNAME Limitations
You cannot create a CNAME for the root domain. This is a DNS protocol restriction. The following is invalid:
# INVALID - root domain cannot be a CNAME
example.com. CNAME hosting-provider.com.
The root domain must have an A or AAAA record because it also needs NS records (for nameservers) and often MX records (for email), and CNAMEs cannot coexist with other record types for the same name.
CNAME records cannot coexist with other record types. If www.example.com has a CNAME, it cannot also have an A, MX, or TXT record with the same name.
Practical CNAME Examples
Third-party service integration:
help.example.com. CNAME example.zendesk.com.
shop.example.com. CNAME shops.myshopify.com.
CDN configuration:
cdn.example.com. CNAME example.cloudfront.net.
www subdomain pointing to root (only valid if the root has an A record, not a CNAME):
www.example.com. CNAME example.com.
MX Records: Routing Email
An MX record (Mail Exchange record) tells email servers where to deliver mail for your domain. Unlike A records that point to a single server, MX records include a priority value to define fallback mail servers.
When to Use MX Records
- Configure email delivery for your domain
- Set up multiple mail servers for redundancy
- Delegate email handling to a third-party provider (Google Workspace, Microsoft 365, Zoho Mail)
Configuration Format
example.com. MX 10 mail.example.com.
example.com. MX 20 mail-backup.example.com.
Each MX record includes:
- Name: typically the root domain (leave blank or use @ in cPanel)
- Type: MX
- Priority: lower numbers are preferred (typically 0-65535)
- Value: the hostname of the mail server (must be a hostname, not an IP address)
Priority and Fallback Logic
When multiple MX records exist, sending mail servers try the lowest priority first. If that server is unavailable, they try the next priority:
example.com. MX 10 mail1.example.com.
example.com. MX 10 mail2.example.com.
example.com. MX 20 mail-backup.example.com.
In this setup:
- mail1 and mail2 have equal priority (10)—senders will try both
- mail-backup (priority 20) is only used if both primary servers are down
Mail Server A Records
The hostnames in MX records must resolve to A or AAAA records. You cannot use a CNAME as an MX target.
example.com. MX 10 mail.example.com.
mail.example.com. A 203.0.113.50
Google Workspace Example
example.com. MX 1 aspmx.l.google.com.
example.com. MX 5 alt1.aspmx.l.google.com.
example.com. MX 5 alt2.aspmx.l.google.com.
example.com. MX 10 alt3.aspmx.l.google.com.
example.com. MX 10 alt4.aspmx.l.google.com.
TXT Records: Storing Text Data
A TXT record stores arbitrary text data in DNS. Originally intended for human-readable notes, TXT records are now heavily used for domain verification, email authentication, and service configuration.
When to Use TXT Records
- Prove domain ownership to third-party services
- Configure SPF, DKIM, and DMARC for email authentication
- Store site verification tokens
- Publish security policies
Configuration Format
example.com. TXT "v=spf1 include:_spf.google.com ~all"
_dmarc.example.com. TXT "v=DMARC1; p=quarantine; rua=mailto:[email protected]"
Common TXT Record Uses
SPF (Sender Policy Framework): Specifies which mail servers can send email on behalf of your domain.
example.com. TXT "v=spf1 mx include:_spf.google.com ~all"
This record allows your MX servers and Google's servers to send mail for example.com.
DKIM (DomainKeys Identified Mail): Contains a public key for email signature verification.
default._domainkey.example.com. TXT "v=DKIM1; k=rsa; p=MIGfMA0GCS..."
DMARC (Domain-based Message Authentication): Defines policy for handling unauthenticated email.
_dmarc.example.com. TXT "v=DMARC1; p=quarantine; rua=mailto:[email protected]"
Domain verification: Prove ownership to Google, Microsoft, or other platforms.
example.com. TXT "google-site-verification=rXOxyZounnZasA8Z7oaD3c14JdjS9aKSWvsR1EbUSIQ"
CAA records (Certificate Authority Authorization): Although CAA is technically its own record type, some DNS providers require you to add them as TXT records.
Multiple TXT Records
A single hostname can have multiple TXT records. Each serves a different purpose and they all coexist:
example.com. TXT "v=spf1 include:_spf.google.com ~all"
example.com. TXT "google-site-verification=rXOxyZounnZasA8Z..."
example.com. TXT "ms=ms12345678"
SRV Records: Service Location
An SRV record (Service record) specifies the hostname and port for specific services. Unlike other record types that only point to servers, SRV records also define which port to use.
When to Use SRV Records
- Configure services that need specific ports (SIP, XMPP, LDAP)
- Set up Microsoft services (Teams, Skype for Business, Exchange Autodiscover)
- Enable service discovery for applications that support SRV lookups
Configuration Format
_service._proto.name. SRV priority weight port target.
Example:
_sip._tcp.example.com. SRV 10 60 5060 sipserver.example.com.
_sip._tcp.example.com. SRV 10 40 5060 sipserver2.example.com.
Each SRV record includes:
- Service: the service name prefixed with underscore (_sip, _xmpp, _ldap)
- Protocol: _tcp or _udp
- Name: usually your domain
- Priority: like MX records, lower numbers are preferred
- Weight: for load balancing between same-priority records
- Port: the TCP or UDP port number
- Target: the hostname of the server (must resolve to an A/AAAA record)
Microsoft 365 SRV Example
_sip._tls.example.com. SRV 100 1 443 sipdir.online.lync.com.
_sipfederationtls._tcp.example.com. SRV 100 1 5061 sipfed.online.lync.com.
Weight and Priority
Priority works like MX records—try the lowest number first.
Weight distributes load among servers with the same priority. Higher weight values receive more traffic:
_xmpp._tcp.example.com. SRV 10 60 5222 xmpp1.example.com.
_xmpp._tcp.example.com. SRV 10 40 5222 xmpp2.example.com.
With these weights, xmpp1 receives approximately 60% of connections and xmpp2 receives 40%.
Checking Your DNS Records
Verify your DNS configuration using dig (Linux/macOS) or nslookup (Windows):
# Check A record
dig example.com A +short
# Check MX records
dig example.com MX +short
# Check TXT records
dig example.com TXT +short
# Check SRV record
dig _sip._tcp.example.com SRV +short
# Query a specific nameserver
dig @8.8.8.8 example.com A
Online tools like DNS Checker let you verify propagation across multiple geographic locations.
Common DNS Configuration Mistakes
Mixing CNAME with other records: A hostname cannot have both a CNAME and any other record type. If you need multiple record types, use A/AAAA records instead.
CNAME at root domain: The root domain (example.com) cannot be a CNAME. Use A and AAAA records for the root.
Missing trailing dots: When entering hostnames in some DNS interfaces, a trailing dot indicates a fully qualified domain name. Without it, your domain might be appended: mail.example.com could become mail.example.com.example.com.
MX records pointing to IP addresses: MX records must point to hostnames, not IP addresses. The hostname then resolves via its own A or AAAA record.
MX records pointing to CNAMEs: While technically allowed in some scenarios, many mail servers reject MX targets that are CNAMEs. Always use A/AAAA records for mail servers.
Low TTL during migration: Lower your TTL values a day or two before making DNS changes so the old records expire quickly. After the change is stable, raise the TTL again to reduce query load.
TTL and Propagation
TTL (Time To Live) controls how long DNS resolvers cache a record before checking for updates. Shorter TTLs (300 seconds) mean changes propagate faster but generate more DNS queries. Longer TTLs (3600-86400 seconds) reduce server load but slow down changes.
When you update a DNS record, the old value remains cached until its TTL expires. Global propagation depends on the old record's TTL, not the new one.
Conclusion
Understanding DNS record types is essential for managing domains, hosting websites, and configuring services. A and AAAA records point hostnames to IP addresses, CNAME records create aliases, MX records route email, TXT records store configuration data and verification tokens, and SRV records specify service locations with port numbers.
Most domain management involves A, CNAME, MX, and TXT records. Configure your records carefully, verify them after changes, and keep TTL values in mind when planning migrations. When in doubt, consult your hosting provider's documentation or use DNS checking tools to validate your configuration before making it live.
