DNS record types explained: A, CNAME, MX, TXT, and when each is used

Learn how the Domain Name System directs internet traffic by dissecting essential DNS record types and their specific configuration rules.

The Domain Name System (DNS) functions as the directory of the Internet, translating human-readable domain names into the numerical IP addresses required by networking protocols. When you type a URL into a browser, a DNS resolver queries authoritative nameservers to fetch specific records associated with that domain. These records determine exactly how web, email, and authentication traffic is routed.

Every DNS record consists of a name, a time-to-live (TTL) value specifying how long the record should be cached, a record type, and the routing data itself. Managing a domain successfully requires understanding which specific record types are designed to handle which specific types of internet traffic.

Routing web traffic: A, AAAA, and CNAME records

The most fundamental DNS record is the 'A' (Address) record, which maps a domain directly to an IPv4 address, such as 192.0.2.1. The modern equivalent for IPv6 networks is the 'AAAA' record. These records form the backbone of web hosting, explicitly telling the internet where the server hosting a specific domain physically resides.

A 'CNAME' (Canonical Name) record operates differently: it maps a domain name to another domain name, rather than an IP address. For example, if you want 'www.example.com' to point to the exact same server as 'example.com', you use a CNAME. A critical restriction in the DNS specification is that a CNAME record cannot coexist with any other record type at the same subdomain hierarchy level.

Handling email and security: MX and TXT records

Mail Exchange (MX) records are exclusively used to direct email sent to your domain. An MX record specifies the mail server responsible for accepting messages, along with a priority number. If you define multiple MX records, the sending server will attempt delivery starting with the lowest priority number, providing built-in fallback redundancy for corporate email systems.

Text (TXT) records were originally designed to hold arbitrary human-readable text, but are now heavily utilized for domain security and verification. Modern email security protocols like SPF, DKIM, and DMARC rely on TXT records to publish cryptographic keys and authorized sender lists, which external mail servers use to verify that incoming emails are legitimate and not spoofed.