DNS Lookup

Erick KamandaErick Kamanda
4 min read

The Phonebook Analogy

The human brain is not well designed to store and remember numbers. Instead, it is very good at remembering names. That is why mobile phones store contacts in the form of a number with a name attached to it. For instance, it is a little harder to remember 079876543xx than just remembering the contact's owner, John. On the other hand, computers are designed to store information in numbers. As seen in the following picture, it is easier for the human brain to remember the names John, Jane, and Doe than the associated phone numbers.

Sample phonebook contacts

Similar to people's phone numbers, each website hosted on the Internet has an IP address, a bunch of unique numbers that can be used to identify them. An example of an IP address is 198. 196. 32. 90. Since it is a little hard for the human brain to store and remember these numbers, people are asked to create domain names for their websites so that instead of remembering the numbers, they can just store and retrieve the names. These names that are given to websites are called Domain Names. An example of a domain name is google.com.

Domain Name System (DNS)

The Domain Name System (DNS) is a phonebook of the Internet. It helps locate the names that users type on the browser to their respective IP addresses, which the computer can then use to locate the desired website and its resources. For instance, if you type "example.com" on your browser and hit ENTER, your browser is going to send the text to the Domain Name System requesting its IP address, which it will then use to ask for information from the Web Server. The picture below illustrates what happens when you type something on your browser and hit ENTER. You must be connected to the Internet though ๐Ÿ˜‚.

A flow diagram showing the steps of DNS look up through the four servers; DNS, root, top level domain (TLD) and authoritative servers

How DNS Works

In a usual DNS query, the URL that a user types on the browser is taken through 4 servers. The four Servers are DNS Recursor/Resolver, Root Name servers, Top Level Domain (TLD) name servers, and Authoritative Name Servers. All four name servers are shown in the above diagram, and below is a step-by-step explanation of what happens at each of them.

Step 1: User Initiates DNS Lookup & Query the DNS resolver: When you enter a URL into your web browser, it initiates a DNS lookup. The browser first checks if the domain's IP address is in its cache. If not, it sends a query to the DNS resolver. The DNS resolver, often provided by your Internet Service Provider (ISP), receives the query.

Step 2: Query the root server: If the DNS resolver does not have the IP address for the entered URL cached, it forwards the query to a root server.

Step 3: Root server's response: The root server responds with information directing the DNS resolver to a Top-Level Domain (TLD) server (like .com or .net) that stores information about that domain and its name servers.

Step 4: Query to TLD Server: Once the DNS resolver receives the TLD from the root server, it then sends a query to the TLD server.

Step 5: TLD server's response: The TLD responds with an address for an Authoritative Name Server responsible for that specific domain.

Step 6: Query to Authoritative Name Server: Next, the DNS resolver sends a query directly to this Authoritative Name Server, asking for the IP address of the given URL.

Step 7: Response from Authoritative Name Server: The Authoritative Name Server has exact information about the URL, and it responds with the IP address of the requested website.

Step 8: DNS Resolver Caches IP Address: The DNS resolver receives this IP address and caches it for future queries before sending it back to the user's computer. After caching, it sends the IP Address to the User's Computer. The user's computer receives and passes this IP address onto its web browser.

Step 9: HTTP Request to Web Server: With this IP address, the web browser now makes an HTTP request directly to the web server of the desired website.

Step 10: Web Server Responds with HTML Content: Finally, the web server responds with HTML content which is rendered on the user's web browser as a webpage. This completes the DNS lookup process.

0
Subscribe to my newsletter

Read articles from Erick Kamanda directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Erick Kamanda
Erick Kamanda

I am a mechanical engineer who is passionate about software engineering. I am currently enrolled in ALX Africa's software engineering course to transition into a full-stack developer. The program will equip me with essential skills in object-oriented programming, C programming language, Python programming language, JavaScript programming language, graphic programming, reverse engineering, security, and database management. With my engineering background, I bring a unique perspective to software engineering, and I am excited about the field's opportunities. I am a hardworking and proactive individual, eager to learn and acquire new skills. I aim to become a skilled, knowledgeable full-stack developer who can solve complex problems and contribute to meaningful projects. I believe that my passion for software engineering, combined with my mechanical engineering skills, will allow me to excel in this field. I am eager to connect with other professionals in the industry and work collaboratively to create innovative solutions that positively impact the world. Thank you for taking the time to read my About section, and I look forward to connecting with you!