Free, independent guides since 2010

Hosting & domains

DNS records explained: A, AAAA, CNAME, MX and TXT

What DNS does and what the most common DNS records mean: A, AAAA, CNAME, MX, TXT, NS and CAA, with examples and tips for changing them safely.

<guide section="Hosting & domains" type="article" read="2 min"/>

When someone types your domain name, their computer has to find out which server to talk to. That lookup is the job of the Domain Name System (DNS), often called the phone book of the internet. Our page on domain nameservers explains who answers those questions; this page explains the answers themselves: the DNS records.

The records you will meet

RecordWhat it doesExample value
APoints a name to an IPv4 address203.0.113.10
AAAAPoints a name to an IPv6 address2001:db8::10
CNAMEMakes a name an alias of another namewww → example.com
MXSays which servers receive email, with a priority10 mail.example.com
TXTFree text, used for verification and email securityv=spf1 include:… -all
NSLists the nameservers for the domainns1.provider.net
CAALimits which certificate authorities may issue certificates0 issue "letsencrypt.org"
SRVPoints to servers for specific servicesUsed by calling and chat apps

A typical small-business setup

Plain text
example.com.        3600  A      203.0.113.10
www.example.com.    3600  CNAME  example.com.
example.com.        3600  MX     10 mx1.mailprovider.net.
example.com.        3600  MX     20 mx2.mailprovider.net.
example.com.        3600  TXT    "v=spf1 include:_spf.mailprovider.net -all"
_dmarc.example.com. 3600  TXT    "v=DMARC1; p=quarantine; rua=mailto:dmarc@example.com"

The website runs on one server, email is handled by a mail provider, and two TXT records protect the domain against email spoofing. Our guide to SPF, DKIM and DMARC explains those in detail.

TTL: why changes are not always instant

Every record has a TTL (time to live) in seconds. Resolvers around the world keep the answer in their cache for that long. With a TTL of 86400 (one day), some visitors may reach your old server for up to a day after a change. Before a planned move – see changing web hosts – lower the TTL to 300 seconds a day in advance, make the change, and raise it again afterwards.

Changing DNS without breaking things

  • Take a screenshot or export of all existing records before you change anything.
  • When you change nameservers, recreate every record at the new provider first – forgotten MX records are the classic cause of lost email.
  • Check the result with a lookup tool or the dig / nslookup command before and after.
  • Consider DNSSEC, which signs your records so they cannot be forged. Many registrars can enable it with one click.

Frequently asked questions

How long does a DNS change take?

Resolvers cache records for the TTL (time to live) of the record, often one hour to one day. Lowering the TTL a day before a change makes the switch almost instant for most visitors.

Can I put a CNAME on my root domain?

Not according to the DNS standard, because the root already has other records. Many DNS providers offer a workaround called ALIAS, ANAME or CNAME flattening.