Skip to main content
DNS Explained – Complete Beginner to Advanced Guide
CHAPTER 06 Beginner

DNS Records Explained

Updated: May 15, 2026
20 min read

# CHAPTER 6

DNS Records Explained

1. Introduction

When you purchase a domain name, you are given access to a DNS management dashboard (your Authoritative Nameserver). This dashboard is blank. You must program it by writing DNS Records (Resource Records). These records are simple, single-line text instructions that tell the global internet exactly where your website files live, which server handles your emails, and how to verify your identity. In this chapter, we will define the most critical DNS records, understand their structural differences, and learn how to configure them for a production environment.

2. Learning Objectives

By the end of this chapter, you will be able to:
  • Configure an A Record and an AAAA Record for IP routing.
  • Differentiate between an A Record and a CNAME alias.
  • Explain how MX records direct email traffic.
  • Understand the security and verification purpose of TXT records.
  • Identify the role of NS and PTR records.

3. Core Routing Records (A, AAAA, CNAME)

A Record (Address Record): The most fundamental record on the internet. It maps a domain name directly to an IPv4 address.
  • *Example Config:* Type: A | Name: @ | Value: 192.168.1.10
*(Note: The @ symbol is shorthand for the "root" or "naked" domain, e.g., mywebsite.com without www).*

AAAA Record (Quad-A Record): Exactly the same as an A Record, but it maps the domain to an IPv6 address.

CNAME Record (Canonical Name): A CNAME does *not* point to an IP address. It points a domain name to *another domain name*. It acts as an alias.

  • *Example Config:* Type: CNAME | Name: www | Value: mywebsite.com
*(Why use this? If you use an A Record for both the root and www, and your IP address changes, you have to update two A Records. If you point www to the root via CNAME, you only ever update the root A Record, and the CNAME automatically follows!)*

4. Email and Security Records (MX, TXT)

MX Record (Mail Exchange): If someone emails contact@mywebsite.com, the internet looks specifically for the MX record. It points to the mail server responsible for accepting your emails (like Google Workspace or Microsoft 365). MX records use a "Priority" number; the internet will try the lowest number first (e.g., Priority 10) and fallback to Priority 20 if the first server is offline.
  • *Example Config:* Type: MX | Name: @ | Value: smtp.google.com | Priority: 10

TXT Record (Text Record): Originally designed for humans to leave readable notes, TXT records are now heavily used by machines for verification. When you sign up for Google Search Console, Google will ask you to add a specific TXT record containing a random code. Once you add it, Google scans your DNS. If it sees the code, it proves mathematically that you are the true owner of the domain.

5. Infrastructure Records (NS, PTR)

NS Record (Nameserver): These records dictate which Authoritative Nameservers hold the *other* records for a domain. If you buy a domain on GoDaddy but want to use Cloudflare to manage it, you change the NS records on GoDaddy to point to Cloudflare's servers.

PTR Record (Pointer Record): The exact opposite of an A Record. Instead of translating a Name to an IP, it translates an IP back to a Name. (We will cover this deeply in Chapter 15).

6. Record Comparison Table

Record TypePurposeValue Example
AMaps domain to IPv4203.0.113.50
AAAAMaps domain to IPv62001:0db8::8a2e
CNAMEAliases a domain to another domainmywebsite.com
MXRoutes inbound emailmail.google.com
TXTText strings for verification/securitygoogle-site-verification=XYZ123
NSDelegates DNS authorityns1.cloudflare.com

7. Command Examples

You can query specific record types using dig.
bash
12345
# Query the MX (Mail) records for google.com
dig MX google.com

# Query the TXT records to see their security configurations
dig TXT google.com

8. Best Practices

  • Never CNAME the Root Domain: Due to the strict rules of the DNS protocol (RFC 1034), you cannot place a CNAME record on the apex/root domain (mywebsite.com). CNAMEs can only be used on subdomains (like www.mywebsite.com or blog.mywebsite.com). The root domain *must* use an A Record.

9. Common Mistakes

  • Confusing Web Hosting with Email Hosting: Beginners often assume that if they point their A Record to a web server (like AWS), their emails will automatically go there too. Web traffic (A Record) and Email traffic (MX Record) are completely independent. You must configure them separately.

10. Mini Project: Configure Basic DNS for a Website

Let's conceptualize setting up a new startup domain: mystartup.com.
  1. 1. The Web Server: You rent a DigitalOcean server with IP 104.20.50.1.
  1. 2. The Email: You buy Google Workspace for @mystartup.com emails.
  1. 3. The Configuration:
  • Create an A Record named @ pointing to 104.20.50.1.
  • Create a CNAME named www pointing to mystartup.com.
  • Create an MX Record named @ pointing to smtp.google.com.
*Result:* Web traffic goes to DigitalOcean, and email traffic goes to Google!

11. Practice Exercises

  1. 1. If your company migrates its website to an entirely new cloud provider with a new IPv4 address, which specific DNS record must you update?
  1. 2. Why is it advantageous to use a CNAME record for subdomains (like blog, shop, portal) instead of multiple A Records?

12. MCQs with Answers

Question 1

Which DNS record type is exclusively responsible for routing inbound electronic mail to the correct server?

Question 2

Which of the following is an invalid configuration according to fundamental DNS RFC rules?

13. Interview Questions

  • Q: Explain the mechanical difference between an A Record and a CNAME Record.
  • Q: A client wants to verify domain ownership with a third-party service (like AWS or Google Search Console) without changing their web traffic or email flow. Which DNS record type should they use?
  • Q: Walk me through the purpose of the Priority number in an MX Record.

14. FAQs

Q: What is an SRV Record? A: An SRV (Service) record is a highly specific record used to specify a host and port for particular services. It is most commonly used in VoIP (Voice over IP) systems and gaming servers (like Minecraft) where the application needs to know exactly which port to connect to without the user typing it.

15. Summary

In Chapter 6, we transitioned from theoretical architecture to practical configuration. We cataloged the essential vocabulary of DNS administration—the Resource Records. We mastered the A and AAAA records responsible for direct IP routing, and utilized the CNAME record for intelligent aliasing. We separated web traffic from email traffic by defining the MX record, and secured domain identity using TXT records. By understanding these individual components, we can now orchestrate complex web infrastructure across multiple cloud providers simultaneously.

16. Next Chapter Recommendation

We know what the Authoritative Server holds (the records). But who is actually asking for them? Let's dive deeper into the workhorses of the internet. Proceed to Chapter 7: Recursive and Authoritative DNS Servers.

Finish this Chapter

Save your progress on your learning path and prepare for coding interview challenges.

Discussion

Join the discussion

Log in or create a free account to participate.

Sort: ·