DNS: Domains, Records, and How the Internet Knows Where to Go ?

RohitRohit
3 min read

What is DNS?

The Domain Name System (DNS) is like the phonebook of the internet. While humans remember domain names like google.com, computers use IP addresses like 142.250.64.78. DNS maps these names to their respective IP addresses, allowing us to use readable names to access websites, apps, and services.

What is a Domain?

A domain is your website’s readable address. It typically includes:

  • Top-Level Domain (TLD): .com, .org, .net, etc.

  • Second-Level Domain: The actual name (e.g., google)

  • Combined: google.com

You can also have subdomains like:

  • www.google.com

  • mail.example.com

  • api.myapp.io

DNS Structure: How It Works

  1. You enter a domain in your browser.

  2. Your device asks a DNS resolver (usually from your ISP).

  3. The resolver queries authoritative DNS servers until it finds the IP address for the domain.

  4. Your browser connects to the IP and loads the website.

This entire process usually takes milliseconds.

Common DNS Record Types

DNS records are instructions stored in the DNS zone file of your domain. They define how your domain behaves and where it should point.

1. A Record (Address Record)

  • Points a domain/subdomain to an IPv4 address.

  • Example:

      Host: @
      Type: A
      Value: 192.0.2.1
    

    This means example.com goes to IP 192.0.2.1.

2. AAAA Record

  • Same as A record, but for IPv6 addresses.

  • Example:

      Host: @
      Type: AAAA
      Value: 2001:db8::1
    

3. CNAME (Canonical Name Record)

  • Maps one domain to another domain name.

  • Cannot be used at the root domain (@).

  • Example:

      Host: www
      Type: CNAME
      Value: yourapp.netlify.app
    

4. ALIAS / ANAME

  • Works like a CNAME but can be used at the root domain.

  • Resolves to an IP address behind the scenes.

  • Used by providers like AWS Route 53, Cloudflare, etc.

5. MX (Mail Exchange Record)

  • Directs email to your mail servers.

  • Example:

      Host: @
      Type: MX
      Value: mail.example.com
      Priority: 10
    

6. TXT (Text Record)

  • Used for human-readable or machine-verifiable text.

  • Often used for:

    • SPF/DKIM/DMARC (email security)

    • Domain verification (e.g., Google Search Console)

  • Example:

      Host: @
      Type: TXT
      Value: "v=spf1 include:_spf.google.com ~all"
    

7. NS (Name Server Record)

  • Specifies which name servers are authoritative for the domain.

  • Changing this transfers DNS control to another provider.

8. PTR (Pointer Record)

  • Used for reverse DNS lookups (IP → domain).

  • Typically configured by your hosting provider.

Special Host Symbols

SymbolMeaning
@Root domain (e.g., example.com)
*Wildcard (matches all subdomains not explicitly defined)
wwwA common subdomain

When to Use Which Record?

Use CaseRecommended Record
Point root domain to an IPA record
Point subdomain to an IPA record
Point subdomain to another domainCNAME
Point root domain to a third-party domainALIAS / ANAME
Setup emailMX + TXT
Verify domain or set SPF/DKIMTXT
0
Subscribe to my newsletter

Read articles from Rohit directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Rohit
Rohit

I'm a results-driven professional skilled in both DevOps and Web Development. Here's a snapshot of what I bring to the table: 💻 DevOps Expertise: AWS Certified Solutions Architect Associate: Proficient in deploying and managing applications in the cloud. Automation Enthusiast: Leveraging Python for task automation, enhancing development workflows. 🔧 Tools & Technologies: Ansible, Terraform, Docker, Prometheus, Kubernetes, Linux, Git, Github Actions, EC2, S3, VPC, R53 and other AWS services. 🌐 Web Development: Proficient in HTML, CSS, JavaScript, React, Redux-toolkit, Node.js, Express.js and Tailwind CSS. Specialized in building high-performance websites with Gatsby.js. Let's connect to discuss how my DevOps skills and frontend expertise can contribute to your projects or team. Open to collaboration and always eager to learn! Aside from my work, I've also contributed to open-source projects, like adding a feature for Focalboard Mattermost.