DNS (Domain Name System)
DNS (Domain Name System) is the distributed, hierarchical system that translates human-readable domain names like devsunite.com into the IP addresses computers use to connect. A lookup checks local caches, then a recursive resolver queries root, TLD and authoritative name servers, and the answer is cached for the record's TTL (time to live).
DNS, the Domain Name System, is the system that turns a domain name you type into a browser, like devsunite.com, into the IP address a computer actually needs to open a connection. Without it, you'd have to memorize a string of numbers for every website you wanted to visit instead of a name.
Why DNS exists
Every device on the internet is reachable by an IP address, something like 142.250.183.14. IP addresses are great for routers and computers, which are built to work with numbers, but they're impossible for humans to remember at scale. DNS solves that by acting as a distributed, hierarchical phone book: you give it a name, it gives you back the address.
It's distributed and hierarchical on purpose. No single server holds every domain name on earth; instead, the lookup is split across layers of servers, each responsible for a piece of the namespace, which is what lets DNS scale to the entire internet without becoming a single point of failure.
How a DNS lookup actually works, step by step
When you type devsunite.com into a browser and hit enter, here's roughly what happens before the page even starts loading:
- Browser cache check. The browser first checks if it already knows the IP address from a recent visit. If it does, the lookup ends here and the connection starts immediately.
- OS cache check. If the browser doesn't have it cached, the operating system checks its own local DNS cache (also called the resolver cache).
- Recursive resolver. If neither cache has an answer, the request goes to a recursive resolver, usually run by your ISP or a public service like Google's 8.8.8.8 or Cloudflare's 1.1.1.1. This resolver's job is to do all the remaining work on your behalf and hand back a final answer.
- Root server. The recursive resolver asks a root DNS server "who handles .com?" The root server doesn't know the answer for devsunite.com specifically, but it knows which server handles the .com top-level domain, and points the resolver there.
- TLD server. The resolver then asks the .com TLD (top-level domain) server "who handles devsunite.com?" The TLD server responds with the address of the authoritative name server for that specific domain.
- Authoritative name server. Finally, the resolver asks the authoritative name server, the one that actually holds devsunite.com's DNS records, for the IP address tied to the domain. This server gives back the real answer.
- Answer returned and cached. The recursive resolver sends the IP address back to your device, and caches it for a set time (the record's TTL, or time to live) so the next lookup for the same domain doesn't have to repeat all these steps.
This whole chain usually completes in well under a second, and most of it is skipped entirely once caching kicks in, which is why repeat visits to the same site feel instant.
A worked example
Suppose devsunite.com's authoritative DNS record has an A record (the record type that maps a name directly to an IPv4 address) pointing to 76.76.21.9, with a TTL of 3600 seconds.
- First visit of the day: your device has nothing cached, so it walks the full chain above, root, then .com TLD, then devsunite.com's authoritative server, and gets back 76.76.21.9. That answer is cached for 3600 seconds (one hour).
- Second visit, 10 minutes later: the cached answer is still valid (10 minutes is well under the 1-hour TTL), so the browser or OS returns 76.76.21.9 immediately, no network round trip to any DNS server needed at all.
- Visit after 2 hours: the cached entry has expired since 2 hours is longer than the 3600-second TTL, so the device does a fresh lookup and re-caches whatever answer it gets back, which would normally be the same IP unless the site's DNS configuration changed in the meantime.
This is exactly why lowering a domain's TTL is one of the first things site operators do before a planned IP change, like moving to a new hosting provider: a shorter TTL means visitors' cached answers expire faster, so the cutover to the new IP reaches everyone sooner.
Where this matters in real systems
Content delivery networks (CDNs) like Cloudflare and Akamai lean on DNS heavily: when you look up a domain served through a CDN, DNS can return a different IP address depending on where in the world your resolver is located, routing you to the nearest edge server instead of one central origin server. This is a big part of how large sites stay fast for users on different continents without needing the user or browser to do anything special.
DNS is also a common target in real attacks, which is exactly why it's a security topic and not just a networking one. DNS spoofing (also called cache poisoning) tricks a resolver into caching a fake IP address for a legitimate domain, redirecting users to a malicious server. DNSSEC (DNS Security Extensions) was built specifically to let resolvers cryptographically verify that a DNS response actually came from the real authoritative server and wasn't tampered with in transit.
What interviewers actually ask about DNS
- "Walk me through what happens between typing a URL and the page loading." DNS resolution is almost always the first thing expected in this answer, before TCP handshake, before HTTP request/response.
- "What's the difference between a recursive resolver and an authoritative name server?" The recursive resolver does the legwork and caches answers on the client's behalf; the authoritative server is the actual source of truth for a specific domain's records.
- "What is a TTL and why does it matter?" Expect this framed around a real scenario, like "why would lowering TTL before a migration help."
- "What DNS record types do you know?" A (IPv4 address), AAAA (IPv6 address), CNAME (alias to another domain name), MX (mail server), and TXT (arbitrary text, often used for domain verification) are the ones worth knowing cold.
- "What is DNS cache poisoning, and how does DNSSEC help?" A good answer connects the attack (a resolver caching a falsified answer) directly to the fix (cryptographic signatures that let a resolver verify authenticity).
Key takeaways
- DNS translates human-readable domain names into the IP addresses computers use to route traffic.
- A lookup walks from local caches, to a recursive resolver, to root servers, to TLD servers, to the authoritative name server, though most real lookups are short-circuited by caching.
- TTL controls how long a resolved answer stays cached before it must be looked up again.
- CDNs use DNS to route users to the nearest edge server based on their resolver's location.
- DNSSEC exists to let resolvers verify that a DNS answer genuinely came from the authoritative source, defending against cache poisoning attacks.
More in Application Layer
Browse all Computer Networks topics
Log in to save which topics you've read across every subject.
Frequently asked questions
Walk me through what happens between typing a URL and the page loading.
DNS resolution is almost always the first thing expected in this answer, before TCP handshake, before HTTP request/response.
What's the difference between a recursive resolver and an authoritative name server?
The recursive resolver does the legwork and caches answers on the client's behalf; the authoritative server is the actual source of truth for a specific domain's records.
What is a TTL and why does it matter?
Expect this framed around a real scenario, like "why would lowering TTL before a migration help."
What DNS record types do you know?
A (IPv4 address), AAAA (IPv6 address), CNAME (alias to another domain name), MX (mail server), and TXT (arbitrary text, often used for domain verification) are the ones worth knowing cold.
What is DNS cache poisoning, and how does DNSSEC help?
A good answer connects the attack (a resolver caching a falsified answer) directly to the fix (cryptographic signatures that let a resolver verify authenticity).