Computer Networks
DNS Records: A, AAAA, CNAME, MX
DNS is not just 'name → IP'. It's a database with different record types: server addresses, mail gateways, cryptographic keys, verification tokens. Understanding record types is the key to configuring domains.
- **Email:** without proper MX, SPF, DKIM your emails will end up in spam
- **CDN/Hosting:** CNAME for connecting Cloudflare, Vercel, Netlify
- **Verification:** TXT for proving domain ownership in Google/AWS
Предварительные знания
A Record - IPv4 Address
**A record** (Address) - the most basic DNS record type. Links a domain name to an IPv4 address. When you visit a site, the browser first looks for an A record.
**Round-robin DNS:** Multiple A records for one domain - the simplest load balancing. DNS returns them in different orders, distributing the load. Downside: does not account for server health.
What does an A record store?
AAAA Record - IPv6 Address
**AAAA record** (Quad-A) - same as A, but for IPv6. The name 'four A's' comes from the fact that IPv6 (128 bits) is 4 times longer than IPv4 (32 bits). Modern websites have both A and AAAA records.
**Happy Eyeballs (RFC 6555):** Browsers request A and AAAA in parallel. If IPv6 works - they use it. If IPv6 is slow or broken - they switch to IPv4 in milliseconds.
Why is the record called AAAA (four A's)?
CNAME - Canonical Name (Alias)
**CNAME** (Canonical Name) - an alias pointing to another domain name. Instead of an IP address, it contains a name. The resolver follows the CNAME chain until it finds an A/AAAA record.
**CNAME limitation:** You cannot put a CNAME on the apex domain (example.com without www). CNAME replaces ALL records for the name, including MX, NS. For apex, use A/AAAA or ALIAS/ANAME (non-standard).
What does a CNAME point to?
MX - Mail Servers
**MX** (Mail Exchanger) - specifies which server accepts mail for a domain. Contains a priority (lower = more important) and a mail server name. When sending to user@example.com, MX for example.com is looked up.
**Without MX:** If there is no MX, mail servers try to deliver to the domain's A record. But this is a fallback - it's better to always have MX. To disable mail: MX with priority 0 and a dot (null MX, RFC 7505).
What does a lower priority number mean in MX?
TXT - Text Records
**TXT** (Text) - arbitrary text data. Originally for comments, now used for verification, SPF, DKIM, DMARC, and other protocols. Machines read TXT just as well as humans.
**TXT limit:** One string - up to 255 characters. For long data (DKIM keys), multiple strings are used and concatenated. The overall UDP packet limit is 512 bytes; for large responses - TCP or EDNS.
TXT records are only for humans (comments)
TXT records are actively used by machines for SPF, DKIM, DMARC, verification, and other protocols
Although TXT was created for text notes, its flexibility made it a universal metadata store. Emails without SPF/DKIM often end up in spam.
What is SPF used for in a TXT record?
Key Ideas
- **A** - IPv4 address; **AAAA** - IPv6 address
- **CNAME** - alias to another name (not on apex!)
- **MX** - mail servers with priorities
- **TXT** - metadata: SPF, DKIM, verification
Related Topics
Record types are part of the larger DNS ecosystem:
- DNS resolution — How records are found and cached
- NS records — Zone delegation and authoritative servers
- DNSSEC — Cryptographic signing of records
Вопросы для размышления
- Why can't you put a CNAME on the apex domain (example.com)?
- How does email work if a domain has no MX record?
- Why do you need both A and AAAA records at the same time?