Networking Tutorial · Core Protocols · Lesson 12 of 28

DNS Record Types

A, AAAA, CNAME, MX, TXT, NS and the cloud's alias records: what each one is for, with examples.

Create a free account to save this page, take notes and track your progress. Sign in

Common record types

Type Holds Example
A IPv4 address www A 93.184.215.14
AAAA IPv6 address www AAAA 2001:db8::1
CNAME another name (an alias) shop CNAME shops.myplatform.net.
MX mail servers, with priorities @ MX 10 mail1.example.com.
TXT text: domain verification, SPF, DKIM, DMARC @ TXT "v=spf1 include:_spf.example.net -all"
NS the authoritative name servers for a zone @ NS ns1.example-dns.net.
CAA which certificate authorities may issue certificates @ CAA 0 issue "letsencrypt.org"
SRV host and port of a service _sip._tcp SRV 10 5 5060 sip.example.com.

CNAME rules

  • A name with a CNAME can't have any other records, so the zone apex (example.com itself, which needs NS and SOA records) can't be a CNAME.
  • Cloud DNS services solve this with alias records: Route 53 alias, Azure DNS alias record sets and Cloudflare CNAME flattening all answer with the target's addresses directly.
Following CNAME chainsTry it yourself
ZONE = {
    ("example.com", "A"): ["93.184.215.14"],
    ("www.example.com", "CNAME"): ["example.com"],
    ("shop.example.com", "CNAME"): ["shops.myplatform.net"],
    ("shops.myplatform.net", "A"): ["198.51.100.40", "198.51.100.41"],
}

def resolve(name, depth=0):
    if (name, "A") in ZONE:
        return ZONE[(name, "A")]
    target = ZONE[(name, "CNAME")][0]
    print("  " * depth + f"{name} is an alias for {target}")
    return resolve(target, depth + 1)

for name in ["www.example.com", "shop.example.com"]:
    print(name, "->", resolve(name))

Output

www.example.com is an alias for example.com
www.example.com -> ['93.184.215.14']
shop.example.com is an alias for shops.myplatform.net
shop.example.com -> ['198.51.100.40', '198.51.100.41']

Email records in one minute

MX says where mail for the domain goes. TXT records with SPF, DKIM and DMARC tell receiving servers which senders are allowed and what to do with messages that fail the checks. Missing these is the most common reason application emails land in spam.

Test yourself

Which record type lists the mail servers for a domain?

  1. A
  2. MX
  3. TXT
  4. NS
Show answer

Answer: MX

MX records list mail servers with priorities. TXT records hold SPF, DKIM and DMARC policies.

Was this page helpful?