Skip to main content

Command Palette

Search for a command to run...

DNS Record Types Explained.

Published
β€’6 min read
DNS Record Types Explained.
A

i was a nobody until the covid-19 and like most of the devs from this covid-19 wave, i too started learning something to transition from that nobody to somebody/someone because i had some spare time during πŸ˜‰ & after all those online classes.

so fast-forward ⏩ to 2025 i am currently a frontend developer who

  • is still learning basics of javascript
  • primarily uses CSS for styling
  • ships a couple of apps every now and then
  • uses react.js as the primary framework

impact:

  • Sep,2022 developed the first website aka current one for MuLearn Foundation
  • 2023 developed the web app for MuLearn Foundation, used by over 30,000+ students
  • 2024 - present co-founded the event management and ticketing platform makemypass.com along with few sub-products such as hoogo, premote, quizit, jusvote, leadx
  • 2025 - present working at ente.io

Have you ever hosted a real website? If so, you've probably seen or forwarded an A Record. But chances are you never searched WHAT IT IS. So let me introduce you to a few such records.

How did you reach here?

You entered a URL in the browser and voilΓ , you're here.

BUT HOW DID YOU REACH HERE?

Most folks don't have an answer because this happens automatically. The browser somehow knows where the website lives, went there, and got you the content.

So how does a browser know where a website lives?

hashnode is just a nickname, not the original name.

Wait what? It's not the real name? Then how is the whole brand built around this NAME?

What i meant was hashnode is just a nickname for the browser. It actually knows the real name of hashnode. So if there's a real name, why aren't we using it?

Because the original name is NOT easy to remember.

It's something like 66.33.60.129 - that's the ORIGINAL NAME for hashnode.com. You might say you'll remember this, but imagine using 100 websites daily and having to remember 100 random numbers. What are the odds of you MESSING IT UP?

Pretty high, right?

This is why browsers use hashnode.com (the nickname) and make our lives easier.

For now, just imagine the browser has a phonebook with this mapping. Let's call this mapping DNS.

1. Browser β†’ DNS β†’ Server (High-level flow)

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”       "Where is asw.in?"        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Browser β”‚ ──────────────────────────────> β”‚   DNS   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
     β”‚                                           β”‚
     β”‚                                           β”‚ Looks up record
     β”‚                                           β–Ό
     β”‚                                      "192.168.1.1"
     β”‚          IP: 192.168.1.1                  β”‚
     β”‚ <β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
     β”‚
     β”‚         Connect to server
     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Server β”‚  (at 192.168.1.1)
β”‚ asw.in  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The A Record

Back to our A Record - what does it do in this whole process?

In simple words, this is the record that actually gives the browser the IP ADDRESS when the browser provides the nickname or domain name.

The A record resolves the domain to the IP Address (IPv4).

Example:

asw.in   A   192.168.1.1

When you visit asw.in, the browser gets the IPv4 address 192.168.1.1 and connects to that server.

2. Domain name to IP mapping using A / AAAA records

Domain Name              DNS Record              IP Address
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ asw.in   β”‚ ───A────>  β”‚   DNS 0  β”‚ ────────>  β”‚  192.168.1.1     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β”‚  Server  β”‚            β”‚  (IPv4)          β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                 β”‚                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ asw.in   β”‚ ──AAAAβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                  β”‚  2001:0db8:85a3  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                    β”‚  ::8a2e:0370     β”‚
                                                β”‚  (IPv6)          β”‚
                                                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The AAAA Record

The AAAA Record also resolves to an IP address, but instead of IPv4, it's IPv6.

Example:

asw.in   AAAA   2001:0db8:85a3:0000:0000:8a2e:0370:7334

Same domain, but now with an IPv6 address for modern networks.

The CNAME Record

Unlike the above records where A and AAAA resolved to IP addresses, the CNAME actually resolves to another domain. Basically just like a redirection.

Like when you visit youtube.com, you're probably redirected to www.youtube.com where www is a subdomain.

A CNAME is like a shortcut name that takes you to the real place.

Example:

www.asw.in   CNAME   asw.in
blog.asw.in  CNAME   hashnode.network

When you visit www.asw.in, it points to asw.in. When you visit blog.asw.in, it points to hashnode.network.

3. CNAME pointing one domain name to another

User types               CNAME Record            Final Resolution
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ www.asw.in   β”‚ ────>  β”‚    CNAME     β”‚ ────>  β”‚   asw.in     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚ www β†’ asw.in β”‚        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β”‚
                                                       β”‚ A Record
                                                       β–Ό
                                                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                                β”‚ 192.168.1.1  β”‚
                                                β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Another example:
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚blog.asw.in   β”‚ ────>  β”‚      CNAME       β”‚ ────>  β”‚ hashnode.network β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚ blog β†’ hashnode  β”‚        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The MX Record

Say i have a domain asw.in and you ask me for my email address. I give you mail@asw.in.

When you send a mail to this address, the sender's mail server asks DNS: "Hey, where should I deliver mail for asw.in?"

DNS looks at the MX record and replies:

asw.in   MX   10   mail.asw.in

This tells the internet: "All emails for @asw.in should be delivered to mail.asw.in"

Example:

asw.in   MX   10   mail.google.com
asw.in   MX   20   backup-mail.google.com

The number (10, 20) is priority - lower number = higher priority. So emails go to mail.google.com first, and if that fails, they try backup-mail.google.com.

4. Email routing using MX records

Email to: user@asw.in
         β”‚
         β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”      "Where do emails for
    β”‚  Sender β”‚       asw.in go?"
    β”‚  Mail   β”‚ ───────────────────────────>  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ Server  β”‚                               β”‚   DNS   β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                                         β”‚
         β”‚                                         β”‚ Checks MX records
         β”‚                                         β–Ό
         β”‚                                    MX 10 mail.google.com
         β”‚                                    MX 20 backup-mail.google.com
         β”‚    Priority 10 (try first)             β”‚
         β”‚ <β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ mail.google.com  β”‚  (Primary mail server)
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚ (if fails)
         β–Ό
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ backup-mail.google   β”‚  (Backup mail server)
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

The TXT Record

This record defines miscellaneous information.

Say Google needs to confirm: "Do you actually own asw.in?"

They give you:

asw.in   TXT   google-site-verification=abc123xyz

Once Google sees this β†’ domain verified. (You can delete it later, but most people keep it.)

Example:

asw.in   TXT   "v=spf1 include:_spf.google.com ~all"
asw.in   TXT   "google-site-verification=abc123xyz"

The first one tells email servers "only Google's servers can send emails from @asw.in" (prevents spam). The second verifies domain ownership for Google Search Console.

The NS Record

NS (Name Server) records tell the internet which servers are authoritative for your domain.

Example:

asw.in   NS   ns1.cloudflare.com
asw.in   NS   ns2.cloudflare.com

5. Simple DNS hierarchy showing NS records

                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                     β”‚  Root DNS    β”‚
                     β”‚   Servers    β”‚
                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β”‚ "Who handles .in domains?"
                            β–Ό
                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                     β”‚  .in TLD     β”‚
                     β”‚   Servers    β”‚
                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β”‚ "Who handles asw.in?"
                            β–Ό
                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€-┐
                     β”‚  NS Records   β”‚
                     β”‚ ns1.cloudflareβ”‚
                     β”‚ ns2.cloudflareβ”‚
                     └──────────────-β”˜
                            β”‚
                            β”‚ "What's the A record for asw.in?"
                            β–Ό
                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                     β”‚ Authoritativeβ”‚
                     β”‚  DNS Server  β”‚
                     β”‚  (Cloudflare)β”‚
                     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β–Ό
                     Returns: 192.168.1.1

Complete DNS Setup Example

6. One complete DNS setup for a small website

Domain: asw.in
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     DNS Records Setup                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                             β”‚
β”‚  NS Records (Nameservers)                                   β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”‚
β”‚  β”‚ asw.in    NS    ns1.cloudflare.com           β”‚           β”‚
β”‚  β”‚ asw.in    NS    ns2.cloudflare.com           β”‚           β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β”‚
β”‚                      β”‚                                      β”‚
β”‚                      β–Ό                                      β”‚
β”‚  A Records (Main domain)                                    β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”‚
β”‚  β”‚ asw.in    A     192.168.1.1                  β”‚           β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β”‚
β”‚                      β”‚                                      β”‚
β”‚                      β–Ό                                      β”‚
β”‚  CNAME Records (Subdomains)                                 β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”‚
β”‚  β”‚ www.asw.in    CNAME    asw.in                β”‚           β”‚
β”‚  β”‚ blog.asw.in   CNAME    hashnode.network      β”‚           β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β”‚
β”‚                      β”‚                                      β”‚
β”‚                      β–Ό                                      β”‚
β”‚  MX Records (Email)                                         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”‚
β”‚  β”‚ asw.in    MX    10    mail.google.com        β”‚           β”‚
β”‚  β”‚ asw.in    MX    20    backup.google.com      β”‚           β”‚ 
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β”‚
β”‚                      β”‚                                      β”‚
β”‚                      β–Ό                                      β”‚
β”‚  TXT Records (Verification & SPF)                           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”‚
β”‚  β”‚ asw.in    TXT   "v=spf1 include:_spf..."     β”‚           β”‚
β”‚  β”‚ asw.in    TXT   "google-site-verification..."β”‚           β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β”‚
β”‚                                                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Result:
βœ“ asw.in β†’ 192.168.1.1
βœ“ www.asw.in β†’ 192.168.1.1 (via CNAME)
βœ“ blog.asw.in β†’ hashnode.network
βœ“ user@asw.in β†’ mail.google.com
βœ“ Domain verified for Google services