DNS Record Types: CNAME and MX
You'll learn how CNAME and MX records enable domain aliases and email routing in DNS.
CNAME: Domain Aliases
A CNAME (Canonical Name) record creates an alias for another domain name. Instead of pointing to an IP address like an A record, it points to another domain.
Think of it like a nickname: if "Bob" is your canonical name, "Bobby" might be your alias. When someone asks for Bobby's phone number, they're redirected to look up Bob instead.
Example:
www.example.com. CNAME example.com.
blog.example.com. CNAME hosting.provider.com.
When a client queries www.example.com, the DNS resolver sees the CNAME and performs another lookup for example.com to get the actual IP address. This is useful when you want multiple domain names to point to the same destination, or when hosting services manage your infrastructure.
Important limitation: A CNAME cannot coexist with other record types for the same name (like A or MX records).
MX: Mail Exchange Records
An MX (Mail Exchange) record specifies which mail servers handle email for a domain. When you send an email to user@example.com, your mail server queries DNS for the MX records of example.com to know where to deliver the message.
Example:
example.com. MX 10 mail1.example.com.
example.com. MX 20 mail2.example.com.
The number (10, 20) is the priority — lower numbers mean higher priority. Mail servers attempt delivery to the lowest priority first, falling back to higher numbers if needed.
Key Takeaway: CNAME records create domain aliases that redirect lookups to another domain name, while MX records direct email to specific mail servers with priority-based failover.