Skip to main content

DNS Records: How A, CNAME, MX, TXT, and NS Work

Domains · 15.08.2025 · 5 min read
Illustration for “DNS Records: How A, CNAME, MX, TXT, and NS Work”

DNS (Domain Name System) turns domain names into IP addresses. When you type zevshost.net, the browser queries a DNS server and gets the server's IP address.

Types of DNS Records

TypePurposeExample
ADomain → IPv4example.com → 1.2.3.4
AAAADomain → IPv6example.com → 2001:db8::1
CNAMEDomain aliaswww → example.com
MXMail servermail.example.com (priority 10)
TXTText informationSPF, DKIM, verification
NSName serversns1.zevshost.net

A Record: Connecting a Site

# Map the domain to the server IP
example.com.   IN A  5.135.49.174
www.example.com IN A  5.135.49.174

CNAME: Alias

# www → main domain (convenient when changing IP)
www   IN CNAME example.com.

# Subdomain for CDN
cdn   IN CNAME cdn.cloudflare.com.
⚠️ CNAME cannot be used for the root domain (@). For an apex domain, use an A record or ALIAS.

MX Record: Mail Setup

# Google Workspace
@  IN MX 1  aspmx.l.google.com.
@  IN MX 5  alt1.aspmx.l.google.com.
@  IN MX 10 alt2.aspmx.l.google.com.

TXT Records: SPF and Verification

# SPF — allowed mail senders
@  IN TXT "v=spf1 include:_spf.google.com ~all"

# Google Search Console verification
@  IN TXT "google-site-verification=xxxxxx"

# DMARC
_dmarc  IN TXT "v=DMARC1; p=none; rua=mailto:dmarc@example.com"

DNS Propagation Time (TTL)

TTL (Time To Live) is how long a record is cached, in seconds. Standard values:

  • 3600 (1 hour) — standard
  • 300 (5 minutes) — before migration
  • 86400 (1 day) — for stable records
💡 Before migrating a site, lower the TTL to 300 for 24 hours. After a successful move, set it back to 3600.

Common Mistakes When Working with DNS Records

MistakeCauseFix
A CNAME is added at the root domain (@), and the zone won't saveRFC 1034 forbids a CNAME at the apex domain if other records (like NS, SOA) already exist thereUse an A record for the root, or an ALIAS/ANAME record type if the provider supports it
Two A records with the same name and different IPs don't behave as expectedThis isn't a bug — DNS returns both IPs via round-robin, distributing load randomly between clients rather than acting as failoverTrue fault tolerance needs actual DNS failover with health checks, not just a second A record
A TXT record longer than 255 characters gets truncatedA single TXT record string is limited to 255 bytes by the DNS standardSplit the long value into several quoted strings — most panels concatenate them automatically
An MX record points to a CNAME, and mail isn't deliveredRFC 2181 requires MX to point to an A/AAAA record, not a CNAMEMake sure the name in the MX record resolves directly to an A record, without a CNAME chain

SRV Records and Other Special Types

Beyond the five main types, DNS supports specialized records for particular services — for example, SRV, which specifies a service's host and port (used by XMPP, SIP, and Minecraft servers).

# SRV record format
_service._proto.name. TTL IN SRV priority weight port target.

# Example for an XMPP server
_xmpp-client._tcp.example.com. 3600 IN SRV 5 0 5222 xmpp.example.com.

For a detailed breakdown of the syntax and practical examples, see the article on DNS SRV records.

Checking DNS Records

# Check all records at once (not all resolvers support ANY)
dig example.com ANY

# Check a specific type
dig example.com MX +short
dig example.com TXT +short

# Query the authoritative server directly instead of through a cache
dig @ns1.zevshost.net example.com A
  • A direct query to the authoritative server (@ns1.zevshost.net) shows the current value without the resolver's cache
  • An empty ANSWER SECTION means no record of that type exists, not a server error
  • The +short flag strips out the boilerplate lines and leaves only the record values

When a Single A Record Is Not Enough

  • You need load balancing across several servers with health checks — simple round-robin over multiple A records doesn't automatically remove a downed server from the answer
  • The site needs to work over IPv6 — a separate AAAA record is required; IPv4-only A records aren't enough
  • You need to route traffic to the nearest data center geographically — that requires Anycast or GeoDNS on top of ordinary A records
  • Mail delivery is required — an MX record is mandatory separately from A; mail servers don't use the domain's A record directly for routing mail

PTR Record: Reverse Mapping from IP to Domain

Unlike an A record (domain to IP), a PTR record does the reverse mapping: IP to domain name. It's critical for mail delivery — many receiving servers reject mail from an IP without a valid PTR record.

# PTR is configured in the zone of the provider that owns the IP, not the domain's zone
5.135.49.174.in-addr.arpa. IN PTR mail.example.com.

For a detailed PTR setup, see the article on reverse DNS (PTR).

Was this article helpful?
← Back to Knowledge Base Ask Support