A, CNAME, MX, TXT, NS — every DNS record type explained with real examples and use cases. The essential reference for domain and subdomain management.
The A record is the most fundamental DNS record. It maps a hostname (like example.com or api.example.com) directly to an IPv4 address. When someone visits your domain, DNS resolution starts by looking up the A record to find which IP address to connect to.
You can have multiple A records for the same hostname pointing to different IP addresses — this is used for round-robin DNS load balancing (each query returns a different IP from the list, distributing traffic across multiple servers). A records have a TTL (Time to Live) that controls how long DNS resolvers cache the record; lower TTL means faster propagation when you change an IP, but more DNS queries.
The AAAA record (quad-A) is the IPv6 equivalent of the A record. It maps a hostname to an IPv6 address. As IPv4 address space has been exhausted, IPv6 adoption is growing. Modern servers, CDNs, and hosting providers increasingly support IPv6. A properly configured website should have both A and AAAA records — visitors with IPv6 connectivity will prefer the AAAA record.
A CNAME record creates an alias — it maps one hostname to another hostname (not directly to an IP). When a DNS resolver looks up a CNAME, it follows the chain to the final A/AAAA record. CNAMEs are useful when you want a subdomain to point to a third-party service that gives you a hostname (not an IP) as their endpoint.
Important limitation: A CNAME record cannot coexist with other record types at the same name. Most critically, you cannot put a CNAME at the root/apex of your domain (example.com), because the apex also needs SOA and NS records. This is why services like Cloudflare offer "CNAME flattening" or "ALIAS" records that allow root domain CNAME-like behavior.
MX records specify which mail servers receive email for your domain. When someone sends an email to user@example.com, the sender's mail server queries the MX record to find which server to deliver to. MX records have a priority number — lower numbers mean higher priority. You typically have 2-3 MX records pointing to different mail servers for redundancy.
Modern email providers (Google Workspace, Microsoft 365, Proton Mail for Business) give you specific MX records to add when setting up your custom domain email. If you change email providers, you update the MX records — and after the TTL expires, email automatically routes to the new provider.
TXT records store arbitrary text associated with a domain. Originally for informational purposes, TXT records are now primarily used for email authentication standards and domain ownership verification.
SPF (Sender Policy Framework): Specifies which servers are authorized to send email for your domain. Helps prevent email spoofing. An SPF record lists your authorized sending IP addresses or mail servers. Recipients' mail servers check SPF to determine if the email appears to be from an authorized source.
DKIM (DomainKeys Identified Mail): Adds a cryptographic signature to outgoing emails that allows recipients to verify the email genuinely came from your domain and wasn't tampered with in transit. Your mail server signs emails with a private key; the corresponding public key is published in a DKIM TXT record at a selector subdomain (e.g., google._domainkey.example.com).
DMARC (Domain-based Message Authentication): Builds on SPF and DKIM to specify what happens to emails that fail authentication — reject them, quarantine them (mark as spam), or just report them. DMARC also provides a reporting mechanism where receiving servers send data about failed authentications to your specified email address.
NS records specify which DNS servers are authoritative for your domain — i.e., which servers hold the "official" DNS records for your domain. When you register a domain, you set NS records to point to your chosen DNS provider (your registrar's nameservers, Cloudflare, AWS Route 53, etc.). All DNS queries for your domain are ultimately directed to these nameservers.
Changing NS records means moving all DNS management to a new provider. The change propagates slowly (NS record TTLs are typically 48-72 hours) and must be made at your domain registrar — not in your current DNS provider's control panel. After an NS change, you must recreate all DNS records at the new provider before switching, to avoid downtime.