DNS record types (A, CNAME, MX, TXT)
A domain’s DNS zone is a short list of typed records. Walk through the ones you will actually meet (A, AAAA, CNAME, MX, TXT, NS) and what a TTL does to each.
In 30 seconds
DNS stores facts about a domain as records, and each record has a type that says what its value means.
A and AAAA give IPv4 and IPv6 addresses. CNAME makes one name an alias for another. MX names the servers that receive mail. TXT carries text for other systems, such as ownership tokens and email policy. NS names the servers in charge of the zone.
Every record also has a TTL: how many seconds others may reuse the answer before asking again.
DNS record types (A, CNAME, MX, TXT), step by step
Two rules left out of the drawings: a name that has a CNAME cannot have any other record, so the bare domain itself cannot be one; and MX and NS must point at names with address records, not at aliases.
- Step 1: A zone is a list of records. Everything DNS knows about example.com is a list of short records. Each has four parts: the name it is about, a TTL (how many seconds an answer may be reused), a type saying what kind of answer it is, and the value. The type decides what the value means.
- Step 2: A and AAAA: addresses. An A record maps a name to a 32-bit IPv4 address. AAAA does the same for a 128-bit IPv6 address: four times as long, hence four As. These are the records that finally let a browser connect. It usually asks for both and uses whichever works.
- Step 3: CNAME: an alias. A CNAME says “this name is just another name for that one”. Asking for www.example.com returns the alias, and the lookup starts again with example.com to reach an address. Move the server and only the one A record changes; every alias follows.
- Step 4: MX: where mail goes. To deliver mail for someone@example.com, a mail server does not look up the A record. It asks for MX records, which name the hosts that accept mail. Each carries a preference number: the lowest is tried first, and higher ones are fallbacks if it does not answer.
- Step 5: TXT: notes for machines. A TXT record holds free text, and other systems decide what it means. A service can ask you to publish a token to prove you control the domain. Email uses TXT for policy: this SPF record says only 192.0.2.25 may send mail as example.com, and everything else should be rejected.
- Step 6: NS: who is in charge. NS records name the servers that hold a zone. The .com servers do not store example.com’s records. They hold its NS records, which send a resolver on to ns1.example.net, where the real answers live. This hand-off is called delegation; real zones list at least two name servers.
- Step 7: TTL: how long to remember. Resolvers keep each answer for its TTL and do not ask again until it runs out. With 3600 seconds, a record changed ten minutes after a lookup is still served stale for the other fifty. A short TTL spreads changes quickly at the cost of more queries.
Try it yourself
Learn this first
Learn next
- Email delivery (SMTP, IMAP, POP3)How a message hops from your outbox to someone else’s inbox. Beginner
- SPF, DKIM and DMARCThree DNS records that let a mail server tell real senders from forged ones. Intermediate
- What happens when you type a URLDNS, TCP, TLS, HTTP and rendering: every stage between pressing Enter and seeing a page. Beginner
Spotted a mistake on this page?