DNS 101: From Googling 'What Is A Nameserver' to Feeling Kinda Smart
If
you're like me, you probably spend some time on YouTube watching how
bridges are built. So I hop onto my browser, type in 153.251.208.65,
and find myself a video. Usually, my grandma types up 8.8.8.8
to figure out if what she heard about an outbreak is actually true.
Okay, nobody does that. Most of us barely remember boituxz.netlify.app, let alone a 192... Fortunately, we don't have to, thanks to a big unsung hero making sure you end up at the right place.
Over the last few weeks, I've slowly moved deeper into the world
of backend—from typing localhost in my
API requests to 127.0.0.1. Both of those
lead to the same place, but it made me beg the question: how?
Which brought me to another question: beyond my localhost,
what else is going on?
This is what gave birth to the post you're reading—planned as a two-part series exploring What's the Web? by looking at DNS and HTTP.
So what's the DNS?
The Domain Name System is what a GPS is to a road user. Simply
put, it keeps a record of domain names and the IP addresses they
belong to. For example, in my earlier example, 8.8.8.8
is for Google. This makes life easier for us users, so we can access
websites without having to cram long strings of numbers.
So DNS stores domains. What are domains?
Think of them as an address to a website on the internet. These domains consist of three parts: Top-Level Domain, Second-Level Domain, and Root Domain.
Top-Level Domain (TLD)
This is the part on the right of your domain—your .com,
.org, .zw.
Notably, there are two types: gTLD and ccTLD.
The former (generic Top-Level Domain) was initially made to tell
you what the website is for—so .com
for commercial sites, .gov for
government sites, and so on. But due to increased demand, we now have
.online, .me,
.name, .biz,
so that may no longer be the case where the ending strictly
represents what the site is for.
ccTLDs (country code Top-Level Domains) are
simpler. As the name suggests, they are for a specific region. That
means .zw for Zimbabwe and so on.
Funny enough—has anyone come across a .us
TLD? Let me know.
\Root Domain
The dot (.).
Yeah, that's it.
Second-Level Domain (SLD)
Much more interesting than the root domain, this is the google
in google.com, the linkedin in
linkedin.com. This is what we fuss over
when registering a domain—trying to juggle something catchy,
wanting your name as a domain, and then finding out boitumelo.com
is $2000. Yikes.
This part of the domain is limited to 63 characters and must
consist of letters, hyphens, and numbers only—A-Z and 0-9. They
also can't start or end with hyphens or have consecutive hyphens. So
no www.-Boitumelo.com. Believe me, I
tried.
Subdomain
These are found to the left of the Second-Level Domain—think
admin.tryhackme.com. They have the same
restrictions as above.
Subdomains serve the purpose of organizing and separating different sections of a website, allowing for distinct content or functionality without needing a separate domain name. They help improve website navigation, target specific audiences, and can be useful for localized content or niche areas.
The MAGIC
So you've typed in your URL—maybe to your API or just
google.com. What happens now?
Your computer checks its local cache to see if it has the address of that domain. This is why websites you've visited before are found faster—not loaded faster, that’s a different cache.
If nothing is found, it goes to the next level: a recursive DNS server, usually provided by your ISP. This server has a cache as well, and for popular sites like Google, the journey usually ends here.
But what if you want to check out my blog, which doesn't have that
many readers? 😂
Well, we go further.
If nothing is found in the recursive server, then we move to the
root server. These just direct you to a TLD server.
So if your site ends in .org, the root
server sends you to the TLD server that handles .org.
These TLD servers then direct you to an authoritative server—this one finally answers your plea for help. An authoritative server stores DNS records of a domain and any updates made to that domain name. The answer is returned to your computer, and you get your site.
A TTL (Time To Live) value comes with the domain records—it determines how long the name should be cached before being cleared.
Oh, and there’s more—there are different types of DNS records
Records
A Records resolve to IPv4 addresses
AAAA Records resolve to IPv6 addresses
MX Records point to mail servers (for email)
TXT Records are text fields where any data can be stored
CNAME Records resolve to another domain
So that summarizes the map of the internet—that’s the DNS
Let me know when you’re ready for part two: HTTP - The Internet’s Waiter
Comments
Post a Comment
Say something Diego!