DNS records are the internet’s phonebook, but the real magic isn’t just looking up numbers; it’s how these entries can be cleverly used to route traffic, verify ownership, and even store arbitrary data.

Let’s see how a simple DNS query unfolds for a typical website.

dig google.com

This command asks a DNS resolver for the IP address of google.com. The resolver might have this information cached, or it might go on a journey: asking a root server, then a .com TLD server, and finally a google.com authoritative server. The authoritative server will respond with an A record, which is a mapping from a domain name to an IPv4 address, like 172.217.160.142. If you’re using IPv6, you’d get an AAAA record instead, pointing to an IPv6 address.

But what if google.com isn’t the actual name being resolved? That’s where CNAME (Canonical Name) records shine. Imagine www.google.com. A CNAME record for www.google.com might point to google.com. This means when you ask for www.google.com, DNS first tells you, "that’s actually google.com," and then you have to ask again for google.com to get its IP address. It’s a way to alias one name to another, useful for pointing multiple hostnames to the same server without duplicating IP addresses.

Now, for email. When you send an email to user@google.com, your mail server doesn’t know google.com’s IP address directly. It consults the MX (Mail Exchanger) records for google.com. These records specify which servers are responsible for receiving mail on behalf of that domain, along with a priority number. A lower priority number means a higher preference. For example, you might see:

google.com.		300	IN	MX	10 smtp.google.com.
google.com.		300	IN	MX	20 alt-smtp.google.com.

This tells your mail server to try sending to smtp.google.com first because it has a priority of 10. If that fails, it can try alt-smtp.google.com with its priority of 20.

TXT (Text) records are incredibly versatile. They allow you to associate arbitrary text strings with a domain. This is commonly used for:

  • SPF (Sender Policy Framework): Helps prevent email spoofing by specifying which mail servers are authorized to send email on behalf of your domain. An SPF record might look like: "v=spf1 include:_spf.google.com ~all". This says that mail from Google’s SPF records is permitted, and any other mail should be treated with suspicion (~all).
  • DKIM (DomainKeys Identified Mail): Provides a way to digitally sign outgoing emails, allowing recipients to verify that the email was indeed sent by the domain owner and hasn’t been tampered with. The public key for verification is stored in a TXT record.
  • Domain Ownership Verification: Services like Google Search Console or SSL certificate providers often require you to add a specific TXT record to your DNS to prove you control the domain.

SRV (Service) records are a bit more specialized. They allow you to specify the location (hostname and port number) of servers for specific services. For instance, a domain might have an SRV record for _sip._tcp.example.com pointing to sipserver.example.com on port 5060. This is crucial for protocols like SIP (Session Initiation Protocol) used in VoIP, or for services like XMPP (Jabber). The record format includes priority and weight, similar to MX records, to handle load balancing and failover.

_sip._tcp.example.com. 86400 IN SRV 10 60 5060 sipserver.example.com.

Here, 10 is the priority, 60 is the weight, and 5060 is the port.

Other less common but still important record types include:

  • NS (Name Server): Specifies the authoritative name servers for a domain. These are fundamental for the DNS hierarchy itself.
  • SOA (Start of Authority): Contains administrative information about the zone, like the primary name server, responsible person’s email, serial number, and various timers.
  • PTR (Pointer): The reverse of an A record. It maps an IP address back to a domain name, used in reverse DNS lookups.

The true power of DNS lies in its extensibility. You can even create custom TXT records for your own application-specific data, as long as you adhere to the formatting rules.

A common pitfall is forgetting that DNS changes, especially CNAME records, can take time to propagate across the internet due to Time-To-Live (TTL) values set on the records. If you change a CNAME from www.example.com pointing to oldserver.example.com to newserver.example.com, clients might still be using the old IP address cached from oldserver.example.com for a while.

Once you’ve mastered these core record types, understanding how DNSSEC (DNS Security Extensions) adds cryptographic signatures to DNS records to prevent spoofing and tampering will be your next logical step.

Want structured learning?

Take the full Dns course →