How Does Your Browser Know Where a Website Lives?
Understanding DNS and the Records That Make the Internet Work
I'll never forget buying my first domain. 2021, lockdown. Built a portfolio website, bought "priyanshumaitra.dev", pointed it to my hosting, and... nothing worked.
I stared at my screen for an hour. Domain: mine. Website: ready. Why wasn't it showing up?
I hadn't set up DNS records. Didn't even know what they were. Thought buying a domain and having a website was enough. It's not.
Let me save you that confusion.
The Simple Question: How Does a Browser Find Your Website?
Think about this: you type "google.com" into your browser and hit enter. Within milliseconds, you're looking at Google's homepage. But here's the thing – computers don't understand "google.com". They work with IP addresses like 142.250.185.46.
So how does your browser translate "google.com" into that number?
That's where DNS comes in. DNS stands for Domain Name System, but forget the technical term. Think of it as the internet's phonebook.
You know how you save contacts in your phone? Instead of remembering that your friend's number is +91-9876543210, you just save it as "Priyanshu" and tap to call. DNS does the same thing for websites. It translates human-friendly names like "google.com" into computer-friendly numbers like 142.250.185.46.
Without DNS, you'd have to memorize IP addresses for every website you visit. Imagine typing 172.217.160.142 every time you wanted to check Facebook. Nobody's doing that.
Why DNS Records Exist
Here's where it gets interesting. DNS isn't just "domain name = IP address". It's more complex because the internet needs more information than just where your website lives.
Think about a business. You don't just need their address. You might also need:
Who owns the building (NS records)
The street address (A records)
Alternative addresses (AAAA records)
Nicknames for the location (CNAME records)
Where to send mail (MX records)
Additional business info (TXT records)
DNS records are different types of information about your domain, stored in a system that the whole internet can access. Each record type serves a specific purpose.
When I finally understood this, everything clicked. Let me break down each record type.
NS Records: Who's In Charge?
NS stands for Name Server. This tells the internet: "Who manages this domain's DNS records?"
Think of it like property ownership. NS record points to who manages the property, not where it is.
When you buy a domain, registrars set their name servers:
ns1.godaddy.com
ns2.godaddy.com
When I moved to Cloudflare, I changed NS records to:
brad.ns.cloudflare.com
elsa.ns.cloudflare.com
Now Cloudflare manages all my DNS. The NS record says, "For questions about myportfolio.tech, ask Cloudflare."
Most beginners don't touch NS records unless changing DNS providers.
A Records: The Main Address
This is the big one. The A record (Address record) maps your domain name to an IPv4 address.
When someone types "myportfolio.tech" into their browser, the A record says: "That website lives at 192.0.2.1" (example IP).
It's literally that simple:
myportfolio.tech -> 192.0.2.1
You can also create subdomain A records:
blog.myportfolio.tech -> 198.51.100.5
api.myportfolio.tech -> 203.0.113.10
Each subdomain can point to a different server. My main site might be on one server, my blog on another, my API on a third. A records make this possible.
The "A" stands for "Address", but specifically IPv4 addresses (the familiar 4-number format like 192.168.1.1).
AAAA Records: The Future Address
AAAA records do the same as A records, but for IPv6 addresses.
IPv6 looks like: 2001:0db8:85a3:0000:0000:8a2e:0370:7334. Longer, uglier, but necessary because we're running out of IPv4 addresses.
Most websites have both:
myportfolio.tech -> 192.0.2.1 (A - IPv4)
myportfolio.tech -> 2001:db8::1 (AAAA - IPv6)
Devices use whichever format they support. Modern devices prefer IPv6, fall back to IPv4.
When I started, I only set up A records. Hosting providers usually handle AAAA automatically. Unless managing your own servers, you might not need to configure these manually.
CNAME Records: The Alias
CNAME stands for Canonical Name. It's an alias - one name pointing to another name.
Here's a real scenario I faced: I had my website hosted on GitHub Pages. GitHub told me to point my domain to username.github.io. But I wanted people to access it via www.myportfolio.tech.
I couldn't create an A record because GitHub Pages doesn't give you a fixed IP address. The IP might change. So I used a CNAME:
www.myportfolio.tech -> username.github.io
Now when someone visits www.myportfolio.tech, DNS says "that's actually an alias for username.github.io" and looks up that address instead.
Here's the key difference between A and CNAME:
A record: Points directly to an IP address
CNAME: Points to another domain name, which then resolves to an IP
Think of it like this: An A record is a street address. A CNAME is "same address as John's place" - you need to look up John's address to find it.
Important rule: You can't use CNAME for your root domain (myportfolio.tech). Only subdomains (www.myportfolio.tech, blog.myportfolio.tech). This confused me for days when I was starting out.
MX Records: How Email Finds You
MX stands for Mail Exchange. These tell the internet where to send emails for your domain.
When someone emails contact@myportfolio.tech, their email server checks your MX records.
myportfolio.tech MX 10 mail.google.com
The number (10) is priority. Lower = higher priority. Multiple mail servers? Email tries the lowest number first.
I use Google Workspace, so my MX records point to Google:
myportfolio.tech MX 1 aspmx.l.google.com
myportfolio.tech MX 5 alt1.aspmx.l.google.com
If the first server is down, email tries the second.
Important: MX records are only for email. Your website can be down and email still works (and vice versa).
TXT Records: The Information Board
TXT records store text information. Like a bulletin board for notes that other services can read.
Common uses:
Domain verification: Proving you own the domain:
myportfolio.tech TXT "google-site-verification=abc123"
Email security (SPF): Which servers can send email from your domain:
myportfolio.tech TXT "v=spf1 include:_spf.google.com ~all"
Prevents spammers from forging emails from your domain.
DKIM and DMARC: More email authentication, stored as TXT records.
You won't create many TXT records yourself. Services like Google or Cloudflare give you exact TXT records to add.
How It All Works Together
Let's see how these records work for priyanshumaitra.dev:
Website visit:
Browser asks: "Where is myportfolio.tech?"
DNS checks NS: "Cloudflare manages this."
Asks Cloudflare: "What's the A record?"
Cloudflare: "192.0.2.1"
Browser connects and loads website.
Email:
Email server: "Where does mail for myportfolio.tech go?"
DNS checks MX: "Send to mail.google.com"
Email delivered to Google's servers.
Google checks TXT records for SPF, DKIM verification.
Subdomain:
Visit
blog.priyanshumaitra.devDNS finds A record at 198.51.100.5 (different server)
Or finds CNAME pointing to hashnode.com/@priyanshumaitra
All records work simultaneously, independently, serving different purposes.
Common Confusions I Had (And You Might Too)
"Can I use both A and CNAME for the same domain?" No. Just pick one. Either point directly to an IP (A record) or point to another domain (CNAME). Not both.
"What's the difference between NS and MX?" NS says who manages ALL your DNS records. MX says where EMAIL goes. Completely different jobs.
"Do I need AAAA records?" Not mandatory, but recommended. Your host probably sets them up automatically.
"Why can't I CNAME my root domain?" Technical reasons involving DNS specifications. Use A records for root domains, CNAME for subdomains.
"How long do DNS changes take?" Usually minutes, sometimes hours. It's called DNS propagation. Different servers update at different speeds.
What I Wish I Knew Earlier
When I bought my first domain, I thought: Buy domain → Point to website → Done.
Reality:
Buy domain
Set NS records (usually automatic)
Set A record to server IP
Set MX records for email
Add TXT records for verification
Maybe CNAME for www subdomain
Wait for DNS propagation
Troubleshoot
Fix the typo in your IP
Wait again
Understanding DNS records saves massive time. Now when something breaks, I check DNS first.
The Bigger Picture
DNS records might seem technical and boring, but they're the foundation of how the internet works. Every website you visit, every email you send, every API you call - DNS is working behind the scenes.
You don't need to be a DNS expert to build websites. Most hosting providers handle the basics automatically. But understanding these records helps you:
Set up custom domains confidently
Troubleshoot when things break
Migrate between hosting providers
Configure custom email addresses
Understand why changes take time to propagate
That first domain I bought? Once I learned about DNS records, I had it working in 20 minutes. The knowledge has saved me countless hours since.
So next time you type a URL and hit enter, remember: there's a whole system of records working together to get you where you need to go. And now you know how it works.
DNS is one of those things that seems complicated until it clicks. Then it's just addresses, aliases, and instructions. If you're setting up your first domain, take it slow, one record at a time. You'll get it.