Nomlen logo

DNS Records Explained: A, CNAME, MX, TXT — What Each One Actually Does

A, CNAME, MX and TXT records explained in plain English: what each DNS record does, real examples, the apex CNAME trap, and the mistakes that break email.

NO
Nomlen
Nov 23, 2026·11 min read
Published November 23, 2026
Updated November 2026
DNS Records Explained: A, CNAME, MX, TXT — What Each One Actually Does
nomlen
11-minute read
Share

Every time someone types your domain into a browser, a quiet lookup happens in under a second: the browser asks the Domain Name System where to go, and a handful of DNS records answer. Most domain owners never look at those records — until the website goes down, email starts bouncing, or a verification step asks them to "add a TXT record". This guide explains the four records you will actually meet — A, CNAME, MX and TXT — in plain English, with real examples and the rules that catch people out. Everything here is checked against the DNS standards (RFC 1034, RFC 1035, RFC 1912) as of November 2026.

Think of your domain's DNS zone as a phone book: each record is one line — a name, a type, and a value. A browser asks for an A record to find the website; a mail server asks for MX records to find where to deliver email; a verification service asks for a TXT record to confirm you own the domain. Every record also carries a TTL (time to live) in seconds: how long resolvers may cache the answer. A TTL of 3600 means one hour; 300 means five minutes — which is why some DNS changes appear instantly and others take a day, as our guide on how long DNS propagation takes explains.

A records: the website's address

An A record maps a hostname to an IPv4 address — the four-number address a server lives at. It is the most basic record in DNS, defined in the original DNS specification, RFC 1035. When a browser looks up example.com, the A record is the answer it gets: "go to 93.184.216.34." If there is no A record for a name, the browser has nowhere to go, and the site fails to load.

Its sibling is the AAAA record, which does the same job for IPv6 addresses. A domain can have both: browsers that support IPv6 prefer the AAAA record, others fall back to the A record.

  • Use an A record when you are given an IP address — by your host, your VPS provider, or a server panel.
  • The risk: an A record points at an IP, and IPs change. If your host migrates your site to a different server, a stale A record points at a dead address until you update it.
  • At the apex: your bare domain (example.com with no subdomain) must use an A or AAAA record for its website. A CNAME is not allowed there — the reason is in the CNAME section below.

CNAME records: the alias

A CNAME (canonical name) record makes one hostname an alias of another hostname. It never contains an IP address — it says "whatever target.example.net resolves to, I resolve to that too."

www.example.com.    3600  IN  CNAME  example.com.
blog.example.com. 3600 IN CNAME sites.provider.com.

The classic use is www: instead of maintaining two A records that must both be updated when the server IP changes, you point www at the apex with a CNAME and keep a single A record. Hosting platforms, CDNs and SaaS tools also hand out CNAME targets constantly — "point shop.yourdomain.com at shops.provider.com" — because the provider can move its own servers without asking you to change anything.

  • A CNAME cannot share its name with any other record. RFC 1034 section 3.6.2 states that if a CNAME record is present at a node, no other data should be present, and RFC 1912 section 2.4 is blunt: "A CNAME record is not allowed to coexist with any other data." Put a CNAME on a name that already has an MX or TXT record and the other records are ignored — mail can stop working with no error anywhere.
  • A CNAME cannot sit at the domain apex. Your bare domain must publish SOA and NS records to function, and since a CNAME cannot coexist with other data, a standard CNAME at the apex breaks the rule. Providers offer look-alikes — ALIAS, ANAME, or CNAME flattening — that resolve the target server-side and publish the result as an A record. Those are the correct way to point an apex at a hostname.

An MX record's target must resolve to an A or AAAA record, never to a CNAME. Pointing your MX at a CNAME hostname is a classic misconfiguration that some mail servers reject outright.

MX records: where email goes

MX (mail exchanger) records tell the world which servers accept email for your domain. Without them, nobody can send you mail at that domain — senders get a bounce.

example.com.   3600  IN  MX  10  mail.example.com.
example.com. 3600 IN MX 20 backup-mail.example.com.

The number before the hostname is the priority, and it works backwards from what most people expect: lower means higher priority. A mail server tries the priority-10 server first and only falls back to priority-20 if the first is unreachable. The fallback server is a spare, not a load balancer — most mail flows through the lowest-numbered MX.

The single most expensive DNS mistake in this whole guide is changing nameservers without recreating MX records at the new provider. Nameserver changes move all DNS answering to the new host — including email routing. If your MX records are not recreated there, incoming mail bounces from the moment the change propagates, and mail sent during the gap is usually lost. Export your zone before any nameserver change, and verify the MX records survived with dig MX yourdomain.com +short or Nomlen's free DNS checker.

TXT records: the Swiss Army knife

A TXT record holds free-form text at a name. Defined in RFC 1035 for human-readable notes, today it is almost entirely machine-readable policy — the record type that email authentication, domain verification and security policies all run on.

The three email-authentication uses dominate:

Protocol
Where it lives
What it does
Example value
SPF
example.com (apex)
Lists which servers may send mail for the domain
v=spf1 include:_spf.google.com ~all
DKIM
selector._domainkey.example.com
Publishes the public key that verifies signed mail
v=DKIM1; k=rsa; p=MIGfMA0G...
DMARC
_dmarc.example.com
Tells receivers what to do with mail that fails SPF/DKIM
v=DMARC1; p=quarantine; rua=mailto:dmarc@example.com
Verification
Apex or a name the service gives you
Proves domain ownership to Google, Microsoft, SSL issuers
A random token the service provides

TXT records have one technical quirk that causes real failures: under RFC 1035, each character string inside a TXT record is limited to 255 octets. A record can hold several strings, joined together with no separator — so long values such as 2048-bit DKIM public keys are published as multiple quoted strings. Most panels split long values automatically; if yours does not and a DKIM key fails to validate, check the value was split rather than truncated at 255 characters.

One rule that catches people out: only one SPF record per domain. You may have dozens of TXT records at the apex, but never more than one beginning v=spf1 — multiple SPF records cause a PermError and receivers treat the policy as invalid (RFC 7208, section 4.5). Merge multiple sending services into a single SPF record, and keep its total DNS lookups under 10.

The four records at a glance

Record
Answers the question
Value is
Can it sit at the apex?
Typical TTL
A
Where is the website?
IPv4 address
Yes — the standard choice
300–3600s
AAAA
Where is the website (IPv6)?
IPv6 address
Yes
300–3600s
CNAME
What other name is this an alias of?
Another hostname
No — use ALIAS/flattening instead
300–3600s
MX
Where does email go?
Priority + mail server hostname
Yes
3600s
TXT
What policies/keys apply here?
Text (SPF, DKIM, DMARC, verification)
Yes
300–3600s

A worked example: a complete zone for a small business

Here is a real, working zone for a small business: website on a VPS, email on Google Workspace, domain verified with Google:

@           3600  IN  A      203.0.113.45
@ 3600 IN AAAA 2001:db8::1
www 3600 IN CNAME example.com.
@ 3600 IN MX 1 aspmx.l.google.com.
@ 3600 IN MX 5 alt1.aspmx.l.google.com.
@ 3600 IN MX 5 alt2.aspmx.l.google.com.
@ 3600 IN MX 10 alt3.aspmx.l.google.com.
@ 3600 IN MX 10 alt4.aspmx.l.google.com.
@ 3600 IN TXT "v=spf1 include:_spf.google.com ~all"
@ 3600 IN TXT "google-site-verification=AbCdEfGh123456"
_dmarc 3600 IN TXT "v=DMARC1; p=quarantine; rua=mailto:dmarc@example.com"
s1._domainkey 3600 IN TXT "v=DKIM1; k=rsa; p=MIGfMA0G..."

Notice the pattern: the apex carries the A record (website) and the MX records (email) side by side — different record types coexist happily at the same name. The only record that demands exclusivity is CNAME, which is why www is the alias and the apex is not. The @ symbol is zone-file shorthand for the bare domain itself.

The other records you will meet

NS (nameserver) records say which servers answer DNS for the domain — set at the registrar, not in the zone. SOA (start of authority) is the zone's administrative record (primary nameserver, serial number, refresh timers), managed by your provider. SRV points a service at a host and port, used by Microsoft 365, Zoom and SIP services. CAA restricts which certificate authorities may issue SSL certificates for the domain — a cheap anti-fraud control worth adding once the basics are right.

Four mistakes that break websites and email

  1. CNAME at the apex. It violates RFC 1034/1912 and can silently kill MX and TXT records at the same name. Use an A record, or your provider's ALIAS/flattening feature.
  2. Two SPF records. Merge them into one — a second SPF record invalidates both.
  3. MX pointing at a CNAME. MX targets must resolve to A/AAAA records. Point the MX at the mail server's real hostname, not an alias.
  4. Changing nameservers without copying the zone. The old records do not follow you. Export everything — especially MX and TXT — before switching, and recreate it at the new provider.

DNS records, done right

Four records carry almost everything a domain does: A points the website at an IP, CNAME aliases one name to another (never at the apex), MX routes the email with lower numbers winning, and TXT carries the policies that prove you own the domain and that your mail is legitimate. Learn those four, keep a copy of your zone before any change, and verify afterwards — dig A example.com +short for the website, dig MX example.com +short for mail, dig TXT example.com +short for SPF records, or Nomlen's DNS checker for the same answers without a terminal. Query a public resolver directly (dig MX example.com @1.1.1.1) to see what the rest of the internet sees, and allow for the old TTL to expire before judging the result.

Frequently asked questions

What is the difference between an A record and a CNAME record?

An A record maps a hostname directly to an IPv4 address; a CNAME maps a hostname to another hostname, which is then resolved separately. Use an A record when you are given an IP address, and a CNAME when a provider gives you a hostname to point at. A CNAME cannot sit at the domain apex or share its name with any other record type.

Can I use a CNAME record for my root domain?

Not as a standard CNAME. RFC 1034 and RFC 1912 forbid it because the apex must carry SOA and NS records, and a CNAME cannot coexist with other data. Use an A or AAAA record at the apex, or your DNS provider's ALIAS, ANAME, or CNAME-flattening feature, which resolves the target server-side and publishes the result as an A record.

What does the number in an MX record mean?

It is the priority, and lower means higher priority — a mail server tries the priority-10 server before the priority-20 one. The higher-numbered servers are fallbacks for when the primary is unreachable, not load balancers.

What is a TXT record used for?

Mostly email authentication and verification. SPF (at the apex) lists authorised sending servers, DKIM (at selector._domainkey) publishes the public key that verifies signed mail, DMARC (at _dmarc) tells receivers what to do with mail that fails those checks, and verification TXT records prove domain ownership to services like Google and Microsoft. Each string inside a TXT record is limited to 255 octets under RFC 1035, so long values are split into multiple quoted strings.

How many SPF records can a domain have?

Exactly one. Multiple SPF records cause a PermError and receivers treat the policy as invalid (RFC 7208, section 4.5). Merge all your sending services into a single record, and keep total DNS lookups under 10.

Why is my website down after I changed a DNS record?

Usually one of three things: the new value is wrong (a typo in an IP or hostname), the old value is still cached somewhere under its old TTL, or a CNAME was placed where it conflicts with other records. Check with dig against a public resolver like 1.1.1.1 and wait out the old TTL.

Do DNS changes affect my email?

Changing A or CNAME records does not, but changing nameservers moves all DNS answering — including MX records — to the new provider. If the MX and TXT records are not recreated there first, incoming mail bounces. Export your zone before a nameserver change and verify the MX records afterwards.

What TTL should I use for DNS records?

3600 seconds (one hour) is a sensible default for stable records. Lower it to 300 seconds a day before a planned change so old values expire quickly, then raise it back — a longer TTL means fewer lookups and faster resolution for visitors.

Share
RC
Written by
Ram Chauhan
Founder, Nomlen

Ram builds Nomlen's domain tools and writes these guides — registrar pricing, renewals, TLDs and naming, with every price and claim checked against live registrar data before it ships.

Writes about
Domain pricingRenewalsTLD guidesNaming