DNS Records Explained: A, AAAA, CNAME, MX and TXT for Beginners
DNS records explained in plain English: what A, AAAA, CNAME, MX and TXT records do, when to use A vs CNAME, and how to read and edit records safely.
By Devma Hosting Team · · 11 min read

DNS records are the instructions that tell the internet where your domain's website, email and services live. In plain terms, an A or AAAA record points a name to a server's IP address, a CNAME points one name to another name, an MX record says which servers receive your email, and a TXT record holds text that other services read, such as verification codes and email policies. This guide gets DNS records explained in plain English so you can read your own zone and edit it without breaking anything.
Key takeaways
- An A record maps a hostname to an IPv4 address, and an AAAA record maps it to an IPv6 address.
- A CNAME makes one hostname an alias of another and cannot share its name with any other record, so a standard CNAME cannot sit on your root domain (example.com).
- MX records must point to a hostname that has A or AAAA records, never to an IP address or a CNAME, and the lowest priority number is tried first.
- A domain can have many TXT records (verification codes, SPF, DMARC), but only one SPF record per name.
- DNS changes show up as cached answers expire according to the old TTL, so query the authoritative nameserver to confirm what is actually published.
What is a DNS record?
Every domain has a zone: a list of records stored on its authoritative nameservers. Those nameservers might belong to your registrar, your web host or a dedicated DNS service. When someone visits your site or emails you, their computer asks a resolver, which asks your nameservers, and the records answer.
Most DNS panels show each record with the same handful of fields:
| Field | What it means | Example |
|---|---|---|
| Name (or Host) | Which hostname the record applies to | @ for the root, www, shop |
| Type | What kind of record it is | A, AAAA, CNAME, MX, TXT |
| Value (or Target, Content) | Where it points or what it says | 192.0.2.10, example.com |
| TTL | How long resolvers may cache the answer, in seconds | 3600 |
| Priority | Order of preference, MX records only | 10 |
One detail trips up almost everyone: most panels add your domain to the Name field automatically. Type www, not www.example.com, or you may end up with www.example.com.example.com. Use @ for the root domain itself.
DNS records explained: the five types that matter most
Here is the short version before we go deeper:
| Type | Points to | Typical use |
|---|---|---|
| A | An IPv4 address | Root domain or subdomain on a server with a fixed IP |
| AAAA | An IPv6 address | Same as A, for servers reachable over IPv6 |
| CNAME | Another hostname | Subdomains pointing at a platform, CDN or SaaS |
| MX | A mail server hostname, with a priority | Receiving email for the domain |
| TXT | Free text | Domain verification, SPF, DKIM, DMARC |
This is what a simple zone looks like in the standard zone file format (the IPs are reserved documentation addresses):
example.com. 3600 IN A 192.0.2.10
example.com. 3600 IN AAAA 2001:db8::10
www.example.com. 3600 IN CNAME example.com.
example.com. 3600 IN MX 10 mail.example.com.
mail.example.com. 3600 IN A 192.0.2.25
example.com. 3600 IN TXT "google-site-verification=abc123"
A record
The A record is the original address record, defined in RFC 1035. It maps a name to a 32-bit IPv4 address such as 192.0.2.10. When your host gives you a server IP, this is the record you create. A name can have more than one A record, in which case resolvers return all of them and clients pick one.
AAAA record
The AAAA ("quad A") record, defined in RFC 3596, does the same job for 128-bit IPv6 addresses like 2001:db8::10. A and AAAA records are independent: a name can have either or both. Only add an AAAA record if your server really answers on that IPv6 address, because visitors on IPv6 networks will try it.
CNAME record
A CNAME (canonical name) says "this name is an alias for that name." If shop.example.com is a CNAME to stores.platform.com, resolvers follow the chain and return whatever addresses the platform publishes. The big advantage: when the platform changes its IPs, you change nothing.
The catch is a strict rule. RFC 1034 section 3.6.2 says that if a name has a CNAME, "no other data should be present." That means no MX, no TXT and no second CNAME on the same name. Most DNS panels will simply refuse to save a record that breaks this rule.
MX record
An MX (mail exchanger) record tells sending servers where to deliver email for your domain. Each one has a priority number and a target hostname, such as 10 mail.example.com. We cover the rules in detail below, because MX mistakes are the ones that cost you real messages.
TXT record
A TXT record holds text. DNS itself does not care what the text says; other services read it. Today TXT records mostly carry domain ownership proofs and email authentication policies. Technically, one TXT record can contain several strings of up to 255 octets each, which consumers like SPF join together (RFC 7208). Some DNS panels, Cloudflare among them, split long values for you automatically.
A record vs CNAME: which should you use?
Use an A (and optionally AAAA) record when you have a fixed IP address, and always for the root domain unless your provider offers a flattening feature. Use a CNAME for subdomains that point at someone else's hostname whose IPs might change.
| Situation | Record to use |
|---|---|
Root domain (example.com) on your own server or VPS |
A, plus AAAA if you have IPv6 |
www on the same server as the root |
CNAME to example.com, or an A record with the same IP |
| Subdomain on a SaaS, CDN or site builder | CNAME to the hostname they give you |
| Subdomain on a server with a fixed IP | A record |
| Root domain on a platform that only gives you a hostname | ALIAS, ANAME or CNAME flattening, if your DNS provider supports it |
If you are on traditional web hosting or a VPS, you will usually be given an IP address, so A records are the natural choice.
Why can't I put a CNAME on my root domain?
The root of your zone (the "apex") must hold SOA and NS records. Since a CNAME cannot coexist with any other data, a standard CNAME at the apex would break the zone. ISC's knowledge base explains the conflict and the alternatives, and AWS describes the same limitation.
What are ALIAS, ANAME and CNAME flattening?
Some DNS providers work around the apex rule. You enter a hostname, and the provider looks up its addresses behind the scenes and serves plain A and AAAA answers. Cloudflare calls this CNAME flattening, which it says "allows you to use a CNAME record at your zone apex." Other providers call it ALIAS or ANAME.
These features are provider-specific, not part of the DNS standard, so they do not behave identically everywhere and some hosts do not offer them at all. If your provider lacks one, use the A records your platform publishes for apex domains.
If you use Cloudflare, note that only A, AAAA and CNAME records can be proxied (the orange cloud). Cloudflare recommends proxying web traffic records but not CNAMEs used to prove domain ownership, which should stay DNS-only.
How do MX records control your email?
MX records follow a few rules that are worth knowing by heart:
- Lower number wins. A server with priority
10is tried before one with20. Records with the same number share the load. - The target must be a hostname with A or AAAA records. RFC 2181 section 10.3 says the name in an MX record "must not be an alias," so never point an MX at a CNAME. You also cannot point it at a bare IP address.
- No MX is not the same as no email. If a domain has no MX record, senders fall back to the domain's A or AAAA record, the "implicit MX" in RFC 5321 section 5.1.
- Mail hostnames stay DNS-only on Cloudflare. MX and TXT records are never proxied, and the hostname your MX points to should not be proxied either.
When you switch email providers, replace the old MX records completely rather than adding the new ones alongside. If you mix two providers' MX records, some mail can still end up at the provider you are leaving, which is rarely what you want. If you are setting up business email, your provider will give you the exact MX values to enter.
What about domains that should never receive email?
For parked domains or web-only domains, RFC 7505 defines a "null MX" that tells senders the domain accepts no mail:
example.com. 3600 IN MX 0 .
This gives senders a fast, clear rejection instead of letting them retry against your web server.
How TXT records handle verification and email policy
You can have many TXT records on the same name. A typical root domain might carry a Google verification string, a Microsoft verification string and an SPF policy all at once. That is normal.
The one exception is SPF: a name may have only one SPF record (the TXT value that starts with v=spf1). If you need to authorize a new sender, edit the existing SPF record instead of creating a second one. DKIM and DMARC are also TXT records, published at special names such as selector._domainkey and _dmarc. Our guide to SPF, DKIM and DMARC covers those in depth, and the SPF & DMARC Generator can build the values for you.
Should I delete verification TXT records after verifying?
No. Services often re-check ownership. Google, for example, uses a TXT record starting with google-site-verification= to verify a Search Console domain property and advises keeping the record in place after verification. Remove it and you can lose verified status later.
The same caution applies to TXT records you do not recognize. Before deleting one, search for its prefix or ask whoever set up your email, analytics or ad accounts. A two-minute check beats a broken integration.
How to read DNS records with a lookup tool
You do not need special software to see what your domain publishes. A browser-based tool such as our DNS Lookup or Google Admin Toolbox Dig shows each record type in seconds.
If you are comfortable in a terminal, dig (macOS, Linux) and nslookup (Windows) do the same job:
# Address records
dig example.com A +short
dig example.com AAAA +short
# Is www a CNAME, and to what?
dig www.example.com CNAME +short
# Mail servers, with priorities
dig example.com MX +short
# All TXT records on the root
dig example.com TXT +short
# Windows equivalent
nslookup -type=TXT example.com
How do I check the authoritative answer instead of a cached one?
Your normal resolver may hand you a cached answer. To see what your DNS provider is actually serving right now, find your nameservers and ask one of them directly:
# Find the authoritative nameservers
dig example.com NS +short
# Ask one of them directly (replace with your real nameserver)
dig @ns1.yourdnsprovider.com example.com A
If the authoritative server shows the new value but your browser does not, the record is correct and you are just waiting for caches to expire.
How to edit DNS records safely
DNS edits are quick, which is exactly why they are easy to get wrong. Follow this routine:
- Confirm where your DNS is hosted. Check the NS records. Editing at your registrar does nothing if the nameservers point to Cloudflare or your host.
- Back up the zone. Export it if your panel allows, or take screenshots of every record.
- Lower the TTL ahead of big changes. For a planned move, dropping the TTL to around 300 seconds a day early makes the switch take effect faster. Our zero-downtime migration guide walks through the full process.
- Change one record at a time. Use
@for the root and short names for subdomains. - Verify against the authoritative nameserver with the
dig @command above. - Wait out the old TTL before judging the result.
- Raise the TTL again once everything works.
A word on "propagation": nothing is pushed around the world. Resolvers that already cached your old record keep using it until its TTL runs out, then fetch the new one. That is why the old TTL, not the new one, decides how long a change takes. On Cloudflare, the "Auto" TTL is 300 seconds, and proxied records always use Auto.
Common DNS mistakes to avoid
- CNAME on the root domain at a provider without flattening, or a CNAME on a name that already has MX or TXT records. This can break email and verification.
- MX pointing at a CNAME or an IP address. Point it at a hostname with A or AAAA records.
- Doubled names like
www.example.com.example.comfrom typing the full domain in the Name field. - A second SPF record instead of editing the first.
- Deleting verification TXT records after the service says you are verified.
- Checking a cached resolver and assuming the change failed.
- Proxying the wrong records on Cloudflare, such as verification CNAMEs or mail hostnames.
- Stale CNAMEs to cancelled services. If
promo.example.comstill points at a platform you no longer use, someone else may be able to claim that hostname there and serve content on your subdomain. This is called subdomain takeover. Delete CNAMEs when you cancel the service. Our security page covers broader site protection.
Other record types you may see
Your zone may contain a few more types. You rarely need to touch them, but it helps to recognize them:
- NS: lists the authoritative nameservers for the zone.
- SOA: start of authority, holding administrative details for the zone.
- CAA: says which certificate authorities may issue SSL certificates for your domain.
- SRV: points specific services (often voice or chat) to a host and port.
- SVCB and HTTPS: newer types from RFC 9460, published in November 2023, that let browsers learn connection details like supported protocols before connecting. Some DNS providers create HTTPS records automatically.
Check your records with our DNS Lookup tool
The fastest way to make this guide stick is to look at your own zone. Run your domain through the free Devma Hosting DNS Lookup, compare what you see with the tables above, and note anything that looks out of place before you edit. If you are registering a new name or moving one, our domains page lets you search, register and transfer in one place.
Frequently asked questions
Where do I edit my domain's DNS records?
You edit DNS records wherever your domain's nameservers point. That might be your registrar, your web host or a DNS service such as Cloudflare. Check your current nameservers with a DNS or WHOIS lookup first, because edits made at a provider that is not authoritative have no effect.
Will changing DNS records take my website or email offline?
Not if you plan the change. Resolvers keep serving the old answer until its TTL expires, so for a while some visitors reach the old server and some reach the new one. Keep the old server or mailbox running until the old TTL has passed, and double-check MX records, since a typo there can delay or bounce mail.
Should my domain have both A and AAAA records?
Only add an AAAA record if your server is genuinely reachable over IPv6. Having just an A record is perfectly fine and very common. An AAAA record that points to a wrong or unreachable IPv6 address can cause connection failures for visitors on IPv6 networks.
What TTL should I use for DNS records?
There is no single correct value. Many sites use around 3600 seconds (one hour) for stable records and drop to about 300 seconds shortly before a planned change. A lower TTL makes changes take effect sooner, while a higher TTL means fewer lookups and more caching.
What is the difference between nameservers and DNS records?
Nameservers are the servers that hold your domain's DNS zone and answer questions about it, and they are listed in NS records set at your registrar. DNS records such as A, CNAME, MX and TXT are the individual entries stored on those nameservers. Change the nameservers and you change which set of records the world sees.
