Skip to content
Techzovia
Guides

DNS records explained: A, CNAME, MX and TXT in plain English

What A, AAAA, CNAME, MX and TXT records do, how to set them up for a website and email, why changes take time to appear, and how to check your records yourself.

By Golam Moktadir6 min read
On this page

Buy a domain, move a website or set up email, and someone will ask you to "add a DNS record." Most people only ever need four record types. This guide explains each one with realistic examples, plus how to check your work and avoid the mistakes that break websites and email.

What DNS actually does

Computers talk to each other using numeric IP addresses. People prefer names like example.com. The Domain Name System (DNS) is the internet's lookup service that connects the two.

Your domain's records live on its name servers, usually run by your registrar, web host or a DNS provider. When someone visits your site, their device asks a DNS resolver, which finds your records and caches the answer for a while.

Every record has the same basic parts:

  • Name (host): which name the record is for, such as @ for the domain itself or www for a subdomain
  • Type: A, AAAA, CNAME, MX, TXT and so on
  • Value: the answer, such as an IP address or another hostname
  • TTL: how long, in seconds, other servers may cache the answer

The record types at a glance

Record What it does Typical value Common use
A Points a name to an IPv4 address 203.0.113.10 Pointing your domain to a web host
AAAA Points a name to an IPv6 address 2001:db8::10 Same as A, for IPv6
CNAME Makes a name an alias of another name example.com www and service subdomains
MX Says which servers accept email for the domain 10 mx1.mailhost.example Receiving email
TXT Holds text that other systems read v=spf1 ... ~all SPF, DKIM, DMARC, domain verification

The examples here use placeholder names and addresses. Always copy the real values from your host or email provider.

A and AAAA records: pointing a domain to a host

An A record maps a name to an IPv4 address. When your web host says "point your domain to 203.0.113.10," you create:

Name Type Value TTL
@ A 203.0.113.10 3600

The @ means "the domain itself" in most DNS panels. An AAAA record ("quad A") does the same job for an IPv6 address. If your host gives you an IPv6 address, add an AAAA record alongside the A record.

CNAME records: aliases like www

A CNAME (canonical name) record says "this name is an alias for that other name." The classic use is making www.example.com follow the main domain:

Name Type Value
www CNAME example.com

Now if your host's IP address changes, you only update the A record, and www follows automatically. Online services often ask for a similar CNAME, such as shop pointing to a hostname they control.

The key rule: a CNAME can't coexist with any other record for the same name. That's why you can't put a standard CNAME on the bare domain (@), which always has NS and SOA records.

MX records: where your email goes

MX (mail exchanger) records tell other mail servers where to deliver email for your domain. Each one has a priority number and a hostname:

Name Type Priority Value
@ MX 10 mx1.mailhost.example
@ MX 20 mx2.mailhost.example

Lower numbers are preferred. Senders try priority 10 first and fall back to 20 if it doesn't answer. Two rules matter here: an MX value must be a hostname, not an IP address, and that hostname must not be a CNAME alias.

When you switch email providers, remove the old provider's MX records. Leaving them in place can send some mail to a mailbox you no longer check.

TXT records: email security and verification

A TXT record holds text that other systems read. The most important uses are email authentication and proving that you own a domain.

SPF: who may send mail as you

SPF lists the servers allowed to send email for your domain. It's a TXT record on the domain itself that starts with v=spf1:

v=spf1 include:_spf.mailhost.example ~all

-all at the end says other senders are not authorized (a "fail"), and ~all is a weaker "softfail." Two rules trip people up: a domain must not have more than one SPF record, and an SPF check may trigger no more than 10 DNS lookups from mechanisms like include. Break either rule and receivers get a permanent error.

DKIM: a signature on every message

DKIM lets your email provider sign outgoing messages. Receivers check the signature against a public key published in DNS as a TXT record under a special name: selector._domainkey.yourdomain. Your provider tells you the selector and gives you the value, which contains the key after p=:

Name Type Value
s1._domainkey TXT v=DKIM1; k=rsa; p=MIIBIjANBg...

Some providers, such as Microsoft 365, ask for CNAME records at that name instead, pointing to keys they manage. Use whichever type your provider specifies.

DMARC: what to do when checks fail

DMARC ties SPF and DKIM together and tells receivers what you want done with mail that fails. It lives at _dmarc.yourdomain:

v=DMARC1; p=none; rua=mailto:dmarc-reports@example.com

The p tag can be none (no preference, just report), quarantine (treat failures as suspicious) or reject. The rua tag is where aggregate reports go. Starting with p=none lets you read reports and fix legitimate senders you forgot before you tighten the policy.

Domain verification

Services like Google Workspace ask you to prove you control a domain by adding a TXT record with a unique code, for example google-site-verification=abcdef123_456wx789yz. You add it to the bare domain (name @ or blank), wait for the service to detect it, then click verify. Follow the service's instructions on whether the record must stay afterward.

TTL and "propagation"

There's no central switch that pushes your change across the internet. "Propagation" really means old cached answers expiring. If your A record had a TTL of 86400 (one day), a resolver that looked it up an hour ago may keep serving the old address for up to another 23 hours.

Two practical habits help:

  1. Lower the TTL before a planned move. A day before switching hosts, drop it to something like 300 seconds, then raise it again afterward.
  2. Be patient with new records. Google's help pages, for example, say a new verification TXT record can take up to 72 hours to be recognized.

How to look up DNS records yourself

You don't need to guess whether a change worked. On macOS and Linux, dig is the standard tool. With no type, it looks up the A record. Add +short for a terse answer:

dig example.com +short
dig www.example.com CNAME +short
dig example.com MX +short
dig example.com TXT +short
dig _dmarc.example.com TXT +short

To ask a specific public resolver instead of your default one, put its address after @:

dig @1.1.1.1 example.com MX

On Windows, use nslookup with -type:

nslookup -type=MX example.com
nslookup -type=TXT _dmarc.example.com
nslookup example.com 1.1.1.1

Prefer a browser? Google's free Admin Toolbox has a web-based Dig (DNS lookup) tool at toolbox.googleapps.com/apps/dig.

Common mistakes

  • Doubling the domain name. Many DNS panels add your domain to the name automatically. Typing www.example.com in the name field can create www.example.com.example.com. Enter just www, or @ for the bare domain.
  • A CNAME next to other records. Don't add a CNAME on a name that already has A, MX or TXT records, and never on @.
  • Two SPF records. Adding a second v=spf1 record for a new service breaks SPF. Merge the new include: into your existing record.
  • MX pointing at an IP address or a CNAME. It must be a hostname with its own A/AAAA records.
  • Forgetting old MX records after changing email providers.
  • Deleting records you don't recognize. An odd TXT record may be a verification something still relies on.

The bottom line

Most DNS work comes down to four records. A (and AAAA) points a name at a server, CNAME makes one name an alias for another, MX routes your email, and TXT carries SPF, DKIM, DMARC and verification codes. Keep one SPF record, keep CNAMEs off the bare domain, respect TTLs when you plan changes, and check your work with dig, nslookup or a web lookup tool before assuming something is broken.

Frequently asked questions

How long do DNS changes take to work?

It depends on the record's TTL, which tells other servers how many seconds they may cache the old answer. Many changes show up within minutes to hours, but some services warn that verification records can take up to 72 hours to be recognized.

Can I use a CNAME record for my bare domain (example.com)?

Not with a standard CNAME. A CNAME can't share a name with any other record, and the bare domain always has NS and SOA records. Use an A (and AAAA) record there instead, and put the CNAME on www.

Can I have two SPF records?

No. The SPF standard says a domain must not have more than one SPF record, and receivers treat multiple records as a permanent error. Merge everything into a single v=spf1 record.

Liked this guide? Get the next one by email

The best new tutorials and guides, a few times a month. Unsubscribe any time.

We'll email you a link to confirm. See our privacy policy.