github icon
github icon
avatar

shafikshaon / Understanding DNS: A Step-by-Step Guide

Created Fri, 07 Apr 2023 14:40:09 +0600 Modified Sun, 25 Feb 2024 20:22:56 +0000
646 Words 4 min

Introduction

The Domain Name System (DNS) plays a crucial role in how we access information online. It translates human-readable domain names into IP addresses that computers can understand. This blog post will provide an easy-to-understand, step-by-step guide on DNS, how it works, and the different components involved in the process.

What is DNS?

DNS is like the phonebook of the Internet, translating domain names into IP addresses. It allows humans to access websites using domain names, like nytimes.com or espn.com, while computers interact using IP addresses. Each device connected to the Internet has a unique IP address, and DNS servers help users avoid memorizing these addresses.

How does DNS work?

DNS resolution involves converting a hostname (e.g., www.example.com) into a computer-friendly IP address (e.g., 192.168.1.1). The process consists of multiple hardware components and requires no interaction from the user’s computer apart from the initial request.

DNS Servers Involved in Loading a Webpage

There are four DNS servers involved in loading a webpage:

a. DNS Recursor: It receives queries from client machines and is responsible for making additional requests to satisfy the client’s DNS query.

b. Root Nameserver: It’s the first step in translating human-readable hostnames into IP addresses and serves as a reference to other, more specific locations.

c. TLD Nameserver: This server is the next step in the search for a specific IP address and hosts the last portion of a hostname (e.g., “com” in example.com).

d. Authoritative Nameserver: This is the final stop in the nameserver query and returns the IP address for the requested hostname back to the DNS Recursor.

Difference Between an Authoritative DNS Server and a Recursive DNS Resolver

The recursive resolver is at the beginning of the DNS query, while the authoritative nameserver is at the end. Recursive resolvers handle requests from clients and track down the DNS record, while authoritative DNS servers hold and are responsible for DNS resource records.

Steps in a DNS Lookup

A typical DNS lookup consists of the following eight steps:

  1. User types a domain name into a web browser, and the query is received by a DNS recursive resolver.
  2. The resolver queries a DNS root nameserver.
  3. The root server responds with the address of a Top Level Domain (TLD) DNS server.
  4. The resolver requests the .com TLD.
  5. The TLD server responds with the IP address of the domain’s nameserver.
  6. The recursive resolver sends a query to the domain’s nameserver.
  7. The IP address for the domain is returned to the resolver from the nameserver.
  8. The DNS resolver responds to the web browser with the IP address of the domain requested.

What is a DNS Resolver?

A DNS resolver is responsible for dealing with the client’s initial request and starting the sequence of queries that ultimately leads to a URL being translated into the necessary IP address.

Types of DNS Queries

There are three types of DNS queries: recursive, iterative, and non-recursive. These queries help optimize the DNS resolution process and reduce the distance traveled during the lookup.

What is DNS Caching? Where Does It Occur?

DNS caching temporarily stores data to improve performance and reliability for data requests. It can occur in various locations, such as the browser, operating system, and DNS infrastructure, each of which stores DNS records for a set amount of time determined by a time-to-live (TTL).

Conclusion

The Domain Name System (DNS) is a vital component of the Internet, translating human-readable domain names into IP addresses and allowing web browsers to access online resources. By understanding the various components of the DNS infrastructure, such as recursive resolvers and authoritative nameservers, as well as the different types of DNS queries and caching, you can better appreciate the complex process behind each DNS lookup. The performance and reliability of the DNS infrastructure have a significant impact on our online experience, making it an essential topic to understand for anyone navigating the digital world.

Commit ID: c5d17ea267e3042c327c7fa17af122cf4c614f7b ∙ View Commit on GitHub