DNS Records Explained
How does a browser know where a website lives? How the domain name ( google.com ) points to IP address ( 142.250.1.1 )?

Every tech kid had this question, “How does a browser know where a website lives?“. Somehow the kid knows that “How wires from sea brings internet to home/area?“.
But now it’s high time to know, How the domain name returns a IP addresses of any webpage / website.
Problem: Computer’s don’t speak English “names like google.com“. Speaks Math, only numbers what they understand. In internet each device or online webpage have IP addresses like 142.250.1.1, So that they can uniquely identify each distinct resources ( devices, webpages, etc. ).

DNS (Domain Name System)
A DNS record is an information stored on a DNS server that tells the internet how to handle a domain. It’s like phonebook of internet, maintains the domain name of along with the IP addresses. Phonebook of internet is called Authoritative DNS Servers.
This stores instructions like:
If the domain is
google.comthen point to142.250.1.1IP address.How to handle request for that domain, via all the DNS records.
DNS is what maintains and helps in navigate the IP addresses. Using DNS records we can set instruction that, which domain to point on which IP.
Let’s explore DNS record types !
A & AAAA Records
The ‘A’ stands for ‘address‘, not for any house. A record indicates the IP address of a given domain name.
For example: If you search google.com, the A record of google.com will point to 142.250.1.1 IP address.
A records only holds IPv4 addresses. If a website has an IPv6 address, it will instead use an ‘AAAA‘ record.
The ‘AAAA‘ is new way to address the domains.
AAAA records hold IPv6 addresses, why not IPv4 ? It was old way to address the domains, and we ran out of it. IPv4 addresses are no more available for new domains.

CNAME Record
So, we stopped at Cloudflare. Let’s say I have a blog hosted on Hashnode, but I bought my domain mayurbadgujar.me from Namecheap. I want people to type blog.mayurbadgujar.me and see my Hashnode blog.
This is where the CNAME Record saves the day. CNAME stands for "Canonical Name," which is just a fancy way of saying "Alias" or "Nickname." It maps one domain name to another domain name, not an IP address.
Why do we do this? Imagine if Hashnode changes their server's IP address tomorrow. If I used an A Record (pointing to their IP), my website would break, and I would have to manually update it. But with a CNAME, I just point blog.mayurbadgujar.me to hashnode.network. Now, Hashnode manages the IP addresses in the background, and I don't have to worry about anything. It’s like telling the internet, "I don't know where Hashnode lives, just go ask them."

MX Record
Now, let's talk about emails. You have a website at mayurbadgujar.me, but you also want to receive emails at hello@mayurbadgujar.me. Does the email go to the same server as your website? Usually, no.
That is why we need the MX Record (Mail Exchange). This record tells the internet exactly which server handles emails for your domain. It is responsible for receiving mails.
Think of it like this: Your A Record is your home address where you live (your webpage). Your MX Record is your P.O. Box at the post office where your letters go (your email). If someone tries to deliver a letter to your house, the MX record tells them, "No, don't leave it here. Take it to the Gmail server down the street." Without this record, your domain cannot receive emails.

TXT Record
Next up is the TXT Record. This one is literally what it sounds like, Text. It holds text notes.
At first, I wondered, Why do I need to leave text notes on my domain? The biggest use case is Verification. Let’s say you want to connect your site to Google Search Console (Login with google). Google needs to know you actually own the domain. They will give you a code and say, "Go paste this in your TXT records." Once you do that, Google checks your DNS, sees the code, and knows you are the real owner. It’s like leaving a sticky note on your front door that says, "Verified Owner: Mayur," so the security guard knows it's actually your house.

NS Record
Finally, we have the NS Record (Name Server). This is the Manager of your domain.
These records point to the authoritative server where all your other records (A, CNAME, MX) are actually stored. When you buy a domain from GoDaddy but you want to manage it on Cloudflare, you change the NS Records. You are essentially telling the internet, "I bought this domain at GoDaddy, but Cloudflare is my manager now. Go ask them for my IP address." Without correct NS records, none of the other records we talked about will work because the browser won't know who to ask.

Conclusion
So, that is the full journey of the "Internet's Phonebook."
A Record: The actual House Address (IP address of webpage).
CNAME: The Nickname or Alias (subdomains).
MX: The Post Office for emails.
TXT: The Sticky Note for verification.
NS: The Manager who holds the list.
Now we have the Phonebook (Records), but who actually looks up the number? In the next blog, we will become Detectives and use the dig command to track down an IP address step-by-step.





