What Exactly Is a Domain Name Server (DNS) 🌐 πŸ”‘? And How Does It Really Work? Simplified Explanation πŸ”

Dipsan Kadariya - Sep 6 - - Dev Community

On the Internet, computers identify each other using unique numbers called IP addresses. An IP address (Internet Protocol address) is a unique identifier assigned to each device on a network. Since computers don't understand human language, you might wonder how websites load when you type something into a web browser, like www.youtube.com. This is where DNS comes into play.

If two people speak different languages, they need a translator for effective communication. Similarly, on the Internet, while computers understand IP addresses and numeric values, we are generally more familiar with English and alphabets. DNS acts as a translator between humans and computers.

DNS maps domain names to their IP addresses. For example, DNS maps www.google.com to its IP address, such as 108.177.122.139. So when a user wants to browse and look up Google, instead of remembering the IP address, we can simply use the domain name.

When we type google.com into the web browser, DNS translates it into the web browser's language, which is an IP address, and provides it to the web browser. The web browser then understands that we want to access google.com, so it contacts the Google server and loads google.com on the computer.

Now that we know what DNS is, To understand how DNS works internally, we need to know about DNS servers. Servers are specialized computers or software systems that provide services, resources, or data to other computers or clients over a network. Servers are computers storing HTML files, images, sounds, videos, and other file types. Servers that work together to provide the IP address of the requested website to the web browser are called DNS servers.

There are four types of DNS:
DNS recursive resolver or DNS resolver, root name server, top-level domain (TLD) name server, and authoritative name server.

1. DNS Recursive Resolver (DNS Resolver)

The DNS recursive resolver is the first point of contact in the DNS query process. It acts as an intermediary between the client (your computer or device) and other DNS servers.

Key points about DNS recursive resolvers:

  • They receive DNS queries (A DNS query is a request for information sent from a DNS client (such as your computer or smartphone) to a DNS server) from client machines through applications like web browsers.
  • Its primary function is to find the IP address associated with a given domain name.
  • It can cache DNS information (previous history) to speed up future requests for the same or similar queries.
  • If the requested information isn't in their cache, they initiate a series of requests to other DNS servers to find the required information.

Example scenario:
When you type "www.youtube.com" into your browser, your computer first sends this query to a DNS recursive resolver, typically provided by your Internet Service Provider (ISP).

2. Root Name Server

Root name servers are at the top of the DNS hierarchy and can be thought of as the starting point for DNS queries.

Key points about root name servers:

  • Root servers don't know the IP addresses of individual websites.
  • Instead, they provide information about the Top-Level Domain (TLD) servers.

Example scenario:
If the DNS resolver doesn't have the IP address for "www.youtube.com" cached, it will ask a root server for the address of the .com TLD server.

3. Top-Level Domain (TLD) Name Server

TLD name servers are responsible for maintaining information for all domain names that share a common domain extension (e.g., .com, .org).

Key points about TLD name servers:

  • They manage the next level in the hierarchy after the root servers.
  • Common TLDs include .com, .org, .net, .edu, and country-code TLDs like .uk, .ca, .jp.
  • They store the IP addresses of authoritative name servers for domains under their TLD.

Example scenario:
The .com TLD name server doesn't know the IP address of "www.youtube.com", but it knows the address of the authoritative name server for the "youtube.com" domain.

4. Authoritative Name Server

The authoritative name server is the final stop in the DNS query journey. It's the server that actually has the needed information about a specific domain.

Key points about authoritative name servers:

  • They host the DNS records for a specific domain.
  • These records include the IP addresses associated with the domain and its subdomains.
  • They are typically managed by the domain owner or their hosting provider.
  • There are usually at least two authoritative name servers for each domain for redundancy.

Example scenario:
The authoritative name server for "youtube.com" knows the IP address for "www.youtube.com" and provides this information back through the chain to your computer.

The DNS Resolution Process in Detail

Simple walk through of how DNS Work:

  1. User Input: You type "www.youtube.com" into your web browser.

  2. Check Local Cache: Your computer first checks its local DNS cache to see if it has recently looked up this domain.

  3. Query DNS Resolver: If the domain is not found locally, your computer sends a request to the DNS recursive resolver provided by your ISP.

  4. Check Resolver Cache: The resolver checks its own cache to see if it has the IP address for "www.youtube.com."

  5. Query Root Server: If the IP address is not in the resolver's cache, it sends a query to a root name server.

  6. Root Server Response: The root server responds with the address of the TLD DNS server for .com domains.

  7. Query TLD Server: The resolver then queries the .com TLD server.

  8. TLD Server Response: The TLD server responds with the IP address of the authoritative name server for "youtube.com."

  9. Query Authoritative Server: The resolver queries the authoritative name server for "youtube.com."

  10. Authoritative Server Response: The authoritative name server responds with the IP address for "www.youtube.com."

  11. Resolver Response: The DNS resolver sends this information back to your computer.

  12. Local Storage and Browser Usage: Your computer stores the IP address in its local cache and your browser uses this IP address to access "www.youtube.com."

Thanks for reading the blog.

. . . . . . . . . .