Name in, number out.
You type instagram.com and the feed opens. You've never typed a number to visit a website in your life. Yet every packet your phone sends needs a number, an IP address, to get anywhere.
So where did the number come from, in the half second before the page appeared?
See it#
You type a site's name on your phone. Tap play, then watch who your phone asks, who that one asks in turn, and what happens the second time you open the same site. The scene uses our own site, tryalgoviz.com; any name works the same way.
Your phone asked just one helper, the resolver. The resolver's memory was empty, so it asked around: the root server pointed it to the .com server, the .com server pointed it to the site's own name server, and that one gave the address. The page loaded, and the resolver kept the address. On the second visit, the resolver answered from its cache, and none of the three servers was asked.
Name it#
That whole chain of asking is how every name you type becomes a number. DNS (the Domain Name System) is the internet's phone book: it turns a name like instagram.com into the IP address your device needs to connect to it.
Names are for you; numbers are for computers. A site's name, like instagram.com, is called a domain name. You met IP addresses in lesson 1.2: every device has one.
How it works#
Your phone tries the nearest places first and only goes further when it has to. The scene started at stop 2; here are all of them, and then how long an answer is kept.
1. Your own device checks first#
Before asking anyone, your device looks in two places of its own:
- The hosts file, a small text file on every computer that pairs names with addresses by hand. On Windows and Linux, by default, it is checked before any DNS question is sent. So if the hosts file says facebook.com is 127.0.0.1 (localhost, this device itself, from lesson 1.2), your laptop goes to itself and the site never opens, even though the rest of the world knows the real address, and no question is ever sent. People use exactly this to block a site.
- The cache, the answers your browser and operating system remember from recent lookups.
Most lookups end right here: you open the same few sites all day.
2. The resolver, your helper#
If both miss, your device sends one question to a DNS resolver. Usually that's your ISP's (Jio's or Airtel's), or a public one like Google's 8.8.8.8 or Cloudflare's 1.1.1.1. Your phone already knows the resolver's number: the Wi-Fi router hands it over along with your phone's own address (lesson 1.2). The resolver has a big cache of its own, shared by everyone who uses it, so a popular name is often already there.
Your device asks the resolver for the final answer and simply waits. That kind of question, "go and find it for me", is called recursive.
3. Root, then .com, then the site's own name server#
If the resolver doesn't have the answer either, it does the legwork, exactly as the scene showed:
- It asks a root server. Root servers sit at the top of DNS. They don't know any site's address, but they know who handles each ending (.com, .org, .in), so the root replies: ask the .com servers.
- It asks a .com server (a top-level domain, or TLD, server). That one knows only about names ending in .com, and replies: ask instagram.com's own name server.
- It asks the site's authoritative name server, the one the site's owner runs or rents. That one holds the real answer, and replies with the IP address.
Each of those three replies is a pointer, and the resolver follows the pointers itself. Those questions are called iterative. So the usual pattern is: your device to the resolver is recursive, the resolver to the other servers is iterative. Root and TLD servers never do the whole hunt for anyone, because they'd be swamped.
The full order, then: hosts file and cache on your device, then the resolver, then the root server, then the .com server, then the authoritative server.
4. Caching, and how long an answer lives#
Every answer comes with a TTL, time to live: how many seconds any cache may keep it before asking again. A site might set 300 seconds (5 minutes) or 86400 seconds (24 hours). Until the TTL runs out, resolvers and devices answer from their copy. That's why your second visit in the scene skipped all three servers.
There's a catch. DNS never pushes updates. If a website moves to a new IP address, every resolver that cached the old one keeps handing it out until its TTL expires. With a TTL of 86400, some users can reach the old server for up to a day. So before a planned move, admins lower the TTL in advance.
Why it matters#
Nearly every connection on the internet starts with a DNS lookup: opening a site, an app talking to its server, an email finding its way. When DNS is slow, everything feels slow; when it fails, a working internet looks dead because no name turns into a number. Big outages have started this way, and "change your DNS to 1.1.1.1" is a common fix for a slow connection.
In interviews these come up as:
| Interviews call it | What you saw |
|---|---|
| DNS | the phone book: name in, IP address out |
| Hosts file | checked first; a hosts entry wins over DNS |
| DNS resolver | the helper your device asks |
| Root server | points to the right TLD server |
| TLD server | knows who handles each name under .com, .org or .in |
| Authoritative server | holds the real answer for a site |
| Recursive vs iterative | device to resolver: find it for me; resolver to the rest: follow the pointers |
| TTL | how long a cached answer may be kept |
What to remember#
- DNS turns a name into the IP address your device needs; names are for people, numbers for computers.
- Order: hosts file and cache first, then the resolver, then root, then the .com server, then the site's authoritative server.
- The hosts file wins over DNS by default.
- Device to resolver is recursive; resolver to root, TLD and authoritative servers is iterative.
- Every answer is cached for its TTL, so a changed address lingers until the TTL runs out.