What is the Domain Name System(DNS)? How does it work?

James Ng
3 min readNov 3, 2023

Call it the address book of the internet.

Let us say you (browser/client) are trying to find a friend (server).

You first check your contact cards for the address — check browser’s cache. No luck.

Luckily, there is a service for that! It is called a DNS Lookup, which is provided by an ISP internet service provider.

A schematic of the Domain Name System Lookup process that starts from the client, then to the DNS system, then back to the client, and then to the server.

You go to your ISP for help. The ISP calls upon a local employee called “Messenger” (DNS recursive resolver) to help with your request to get the address (IP address) — after taking your fee of course! 😅

Messenger loves to work smarter, not harder. He also checks his contact cards (check DNS cache) to see if he has your friend’s information.

If he has the address, then he will simply give you it. Unfortunately, no luck either! Therefore, he puts on his shoes and gets moving.

First, Messenger goes to the first department called the “root nameserver”, with the your friend’s full name.

The folks there look at your friend’s last name (domain extensions, such as .com, .org, .net) and then direct Messenger to the appropriate building in the second department called the “TLD (top-level domain) nameserver”.

It has two buildings called Generic TLDs and Country Code TLDs:

  • Generic TLDs have information on people all over the world (ext.— .com, .org, .net, .edu)
  • Country Code TLDs have information on local people (ext. — .us, .ru, .ca, .jp)

The folks in the building direct Messenger to a third department called the “authoritative nameserver”. Two things can happen there. The folks can

  1. Check the database (DNS A records) and return with the friend’s address
  2. Find that your friend goes by another name (alias) in another database (CNAME records).

Messenger prays that they come back with the address or else he would have to go back to the first department and start over again — repeat the DNS Lookup! 😬

Let us say Messenger gets the address. After a sigh of relief, he returns to you with the address.

Messenger also makes contact cards with your friend’s information; he gives you one so you do not forget next time and brings another back to office for future reference (store IP address in browser’s cache or DNS infrastructure).

You go on your way to locate your friend at the address.

When you guys finally get connected, both of you instantly become chatty!

A schematic that shows an established connection between client and server.
Established connection between client and server.

TLDR:

  • DNS (Domain Name Server) is the address book of the internet
  • When you (browser) try to find a friend (server), your ISP (internet service provider) calls a local Messenger (DNS recursive resolver) to help you find his/her address (IP address)
  • Messenger wants to work smarter and not harder so he checks his contact cards (cache) to see if he has your friend’s address
  • If he does, he will give you the address. If not, then he will visit three different departments (root, TLD, and authoritative nameservers) to help you find the address
  • Messenger returns with the address and gives you the contact card for future reference — store IP address in browser’s cache. He also makes note of it himself — store IP address in DNS infrastructure.
  • You connect with your friend, and start chit-chatting away

--

--

James Ng

Software engineer, math & physics educator, mentor