Lesson 5 of 15
4. DNS

4.4 What kinds of DNS records are there?

3 min read+10 XP

In your phone's contacts: One contact card can hold several things: a mobile number, an "also known as" nickname, an email address, a note ("works at the bank"), and who to ask for this person's details. Each has its own field.

In the system: A DNS zone (all the records for a domain) is a list of records. Each has a name, a type, a value and a TTL.

4.4.1 A and AAAA: the address

In your phone's contacts: The actual phone number.

In the system:

  • A record: name → IPv4 address. shop.example.com. 300 IN A 203.0.113.20
  • AAAA ("quad-A") record: name → IPv6 address. shop.example.com. 300 IN AAAA 2001:db8::20

The name comes from size: an IPv6 address is 128 bits, four times the 32 bits of IPv4, so four As. A name can have several A records (4.6).

4.4.2 CNAME: "call them instead"

In your phone's contacts: A nickname entry that says "Ravi's shop: see Ravi". It doesn't hold a number; it points to another name, and you look that one up.

In the system: A CNAME (canonical name) record says "this name is an alias of that name".

www.example.com. 300 IN CNAME example.com. example.com. 300 IN A 203.0.113.10

The resolver follows the alias and returns the final address. CNAMEs are how you point your domain at a service you don't control: shop.example.com CNAME stores.someplatform.net, and when the platform changes its IP addresses, you change nothing.

Two rules that catch people:

  • A CNAME can't share its name with any other record. If www is a CNAME, it can't also have an MX or TXT record.
  • So you can't put a CNAME at the root of your domain (example.com itself), because that name must also hold NS and SOA records. Many DNS providers offer a workaround (called ALIAS, ANAME or "CNAME flattening") that behaves like a CNAME but answers with plain A records. It's a provider feature, not part of the DNS standard.

4.4.3 MX, TXT and NS: mail, notes and who's in charge

In your phone's contacts: The email field, the notes field, and "for this person, ask their office".

In the system:

  • MX (mail exchanger): which servers accept email for the domain, each with a priority number. Lower number = preferred. example.com. MX 10 mail1.example.com. and MX 20 mail2.example.com. mean "try mail1, fall back to mail2".
  • TXT: free text. Mostly used to prove things: that you own the domain (services ask you to add a TXT value), and which servers may send email for you (SPF, DKIM and DMARC records live in TXT).
  • NS (name server): which servers are authoritative for a zone. This is how the .com servers delegate example.com to ns1.example.com, the referral in 4.3.

Memory code: "A for Address (quad-A for the four-times-longer IPv6), CNAME for 'call them instead', MX for Mail, TXT for proofs, NS for who's in charge."