Domain Name System (DNS)

RoadmapsCore CS

Scenario

Computers route traffic using numeric IP addresses, but humans are terrible at memorizing numbers. If we had to type '142.250.190.46' to visit Google, the internet would be unusable.

How does your device translate a domain name into an IP address in milliseconds?

Mental model

DNS is the phonebook of the internet.

You look up a person by their name (google.com) to find their phone number (142.250.190.46) so your device knows exactly who to call.

Explanation

The Domain Name System (DNS) is a hierarchical and decentralized naming system for computers connected to the internet. Its primary purpose is to translate memorable human-friendly domain names (like 'github.com') into machine-friendly IP addresses. Because there are billions of devices, no single server can hold all the mappings. Instead, DNS distributes this directory across thousands of servers worldwide.

When you type a URL into your browser, the first step is checking your local cache—your computer might already remember the IP address from a recent visit. If not, your computer asks a DNS Resolver, typically provided by your Internet Service Provider (ISP) or a public service like Google's 8.8.8.8. The Resolver's job is to hunt down the IP address on your behalf, navigating the DNS hierarchy.

If the Resolver doesn't have the answer cached, it starts at the top by querying a Root Name Server. The Root server doesn't know the exact IP, but it knows which Top-Level Domain (TLD) server handles '.com' or '.org' extensions. The Resolver then asks the TLD server, which in turn directs the Resolver to the Authoritative Name Server for that specific domain (e.g., the server specifically managing 'github.com').

The Authoritative Name Server is the final stop. It holds the official DNS records for the domain. It returns the exact IP address to the Resolver, which caches the result to speed up future requests and finally hands the IP back to your browser. Your browser can now establish a direct connection with the web server.

DNS relies heavily on different types of records. An 'A' record maps a domain directly to an IPv4 address, while an 'AAAA' record maps it to an IPv6 address. A 'CNAME' record aliases one domain name to another, acting like a redirect. By caching responses at every level (browser, OS, Resolver), DNS remains incredibly fast despite the complex global lookup process required for a cache miss.

Key points

Common mistakes

Glossary

Domain Name System
The internet's phonebook that automatically translates human-readable website names into the computer-friendly IP addresses needed to load them.
decentralized
A system design where power and information are spread out across many different computers worldwide, rather than being controlled by a single central server.
local cache
A temporary, super-fast storage area on your computer that remembers recently visited website IP addresses so you don't have to look them up again.

Recall questions

Questions & answers

Which DNS server is at the top of the DNS hierarchy and provides the IP address of TLD servers?

Root Name Server

Approach: The DNS lookup sequence goes: Resolver -> Root -> TLD -> Authoritative. The Root server is the starting point that knows where the .com, .org, etc., servers live.

If you want the domain 'blog.mysite.com' to point to exactly the same IP address as 'mysite.com', which DNS record type is best practice to use?

CNAME Record

Approach: A CNAME allows you to alias 'blog.mysite.com' to 'mysite.com'. If 'mysite.com' changes its IP (its A record), 'blog.mysite.com' will automatically route to the new IP without needing an update.

Return to Core CS Roadmap