A practical guide to DNS records

What A, AAAA, CNAME, MX and TXT records do, and how to check them from a terminal.

•

Published on

•

Do not index
Do not index
DNS turns a name like example.com into the addresses and settings that the rest of the internet needs. A domain's settings live in records, and each record type answers one question.

The records you'll meet most

Type
Answers
Example value
A
Which IPv4 address serves this name?
192.0.2.10
AAAA
Which IPv6 address serves this name?
2001:db8::10
CNAME
Which other name should I look up instead?
shop.example-host.com
MX
Which server receives this domain's email?
10 mail.example.com
TXT
What free-form text does this domain publish?
v=spf1 include:_spf.example.com ~all
NS
Which servers hold this domain's records?
ns1.example-dns.com

CNAME records

A CNAME points one name at another name, not at an address. Hosting providers often ask for one because it lets them change their own server addresses without asking every customer to update DNS.
Two rules trip people up:
  • A name with a CNAME can't have other records of its own.
  • The root of a domain (example.com itself) can't use a plain CNAME. Many DNS providers offer a workaround called CNAME flattening, or an ALIAS record, which looks up the target and answers with its addresses.

TXT records

TXT records hold text that other systems read. The common uses are email rules (SPF, DKIM, DMARC) and proving to a service that you control a domain. A service gives you a value, you publish it, and the service looks it up.

Checking records

dig +short example.com A
dig +short www.example.com CNAME
dig +short example.com MX
dig +short example.com TXT
dig asks your resolver, so a change you just made may not show yet. Asking a public resolver directly, for example dig @1.1.1.1 example.com, gives a second opinion.

How long changes take

Every record has a TTL, the number of seconds resolvers may keep a cached answer. If a record had a TTL of 3600, some visitors may see the old value for up to an hour after you change it. Lowering the TTL a day before a planned change makes the switch faster.