What Is DNS (Domain Name System)?

Published May 16, 2024

Domain Name System (DNS) is an important part of the internet that changes human-readable domain names into machine-readable IP addresses. This article will explain the parts of DNS, including its pieces, query types, and the lookup process. We will also talk about DNS caching and how it makes the DNS resolution process faster.

Key Takeaways

  • DNS acts as the internet's "phonebook," translating human-readable domain names into machine-readable IP addresses
  • The DNS resolution process involves the DNS resolver, root nameserver, TLD nameserver, and authoritative nameserver working together to resolve a domain name
  • DNS recursor, root nameserver, TLD nameserver, and authoritative nameserver are the key components of the DNS system
  • Recursive, iterative, and non-recursive queries are the main types of DNS queries, each serving a specific purpose in the resolution process
  • DNS caching improves performance, reduces bandwidth usage, and lessens the load on upstream servers by storing frequently requested DNS records closer to the client

What is DNS?

DNS, or Domain Name System, is the internet's naming system that acts as the "phonebook" of the internet. Its purpose is to translate human-readable domain names, such as example.com, into machine-readable IP addresses, like 192.168.1.1. This translation lets you use easy-to-remember domain names instead of needing to remember numerical IP addresses when accessing websites or other online resources.

DNS plays a role in the working of the internet by providing a way for devices to communicate with each other using domain names rather than IP addresses. Without DNS, you would need to remember the IP address of every website you want to visit, making browsing the internet harder and less user-friendly.

How DNS works

The process of DNS resolution involves converting a hostname (like www.example.com) into an IP address (such as 192.168.1.1). When you enter a domain name into your web browser, a DNS query is started to translate the domain name into its IP address.

This query involves multiple DNS servers working together to resolve the domain name:

  1. DNS resolver: The DNS resolver is the first stop for your DNS query. It acts like a librarian who gets a request and is responsible for finding the right IP address for the requested domain.

  2. Root nameserver: If the DNS resolver does not have the IP address cached, it sends a query to the root nameserver. The root server acts as a reference point, directing the query to the right Top Level Domain (TLD) nameserver.

  3. TLD nameserver: The Top Level Domain nameserver handles the last part of a domain name, such as .com or .org. It provides the IP address of the domain's authoritative nameserver.

  4. Authoritative nameserver: The authoritative nameserver is the last stop in the DNS query. It holds the actual IP address record for the requested domain and sends this information back to the DNS resolver.

Once the DNS resolver gets the IP address from the authoritative nameserver, it sends this information back to you, allowing your web browser to connect to the right server and load the requested website.

Here's a summary of the DNS resolution process:

Step Server Description
1 DNS resolver Gets your DNS query and is responsible for finding the IP address
2 Root nameserver Acts as a reference point, directing the query to the right TLD nameserver
3 TLD nameserver Handles the last part of the domain name and provides the authoritative nameserver
4 Authoritative nameserver Holds the actual IP address record for the requested domain

Real-life examples of the DNS resolution process:

  • When you type "amazon.com" into your web browser:

    1. The DNS resolver gets the query and checks its cache for the IP address.
    2. If not found, the resolver sends a query to the root nameserver.
    3. The root nameserver directs the query to the .com TLD nameserver.
    4. The .com TLD nameserver provides the IP address of Amazon's authoritative nameserver.
    5. The authoritative nameserver sends the IP address of amazon.com back to the DNS resolver.
    6. The DNS resolver caches the IP address and sends it back to your web browser.
  • When setting up a new website, the domain name (e.g., mynewwebsite.com) must be registered with a domain registrar, and the DNS records must be set up to point to the server hosting the website. This makes sure that when you type "mynewwebsite.com" into your browser, the DNS resolution process can translate the domain name into the right IP address, allowing you to access the website.

Components of DNS

The Domain Name System (DNS) is a part of the internet infrastructure that translates domain names into IP addresses. Several components work together to do this, including the DNS recursor, root nameserver, TLD nameserver, and authoritative nameserver.

DNS Recursor

The DNS recursor, also called a recursive resolver, is the first stop in the DNS query process. It receives queries from client machines like computers or phones and acts like a librarian, finding the requested information to answer the client's query.

Example: When you type www.example.com into your web browser, your operating system sends a query to the DNS recursor to find the corresponding IP address.

Function Description
Receives queries The recursor receives queries from client machines, such as computers or mobile devices
Checks local cache The recursor first checks its local DNS cache for the requested IP address
Makes additional requests If the IP address is not in the cache, the recursor makes additional requests to other DNS servers

Root Nameserver

The root nameserver is the first step in resolving domain names into IP addresses when the recursor does not have the necessary information in its cache. It acts as a reference point for the DNS system, directing queries to the right Top Level Domain (TLD) nameserver.

Example: If the recursor doesn't have the IP address for www.example.com in its cache, it will contact one of the 13 root nameservers to find the right TLD nameserver for the .com domain.

Function Description
Acts as a reference point The root nameserver serves as a starting point for the DNS query process
Directs queries It directs queries to the right TLD nameserver based on the domain extension

TLD Nameserver

The Top Level Domain (TLD) nameserver handles queries for specific domain extensions, such as .com, .net, or .org. It hosts the last part of a domain name and helps narrow down the search for the IP address.

Example: When the recursor contacts the TLD nameserver for .com, it receives the IP address of the authoritative nameserver for example.com.

Function Description
Handles specific domain extensions The TLD nameserver manages queries for specific domain extensions
Provides authoritative nameserver IP It returns the IP address of the domain's authoritative nameserver to the recursor

Authoritative Nameserver

The authoritative nameserver is the final stop in the DNS query process. It holds the actual DNS record for the requested domain, including the IP address. When the authoritative nameserver receives a query from the recursor, it returns the IP address, allowing the client to connect to the right server.

Example: The authoritative nameserver for example.com will provide the IP address for www.example.com to the recursor, which then returns it to the client machine.

Function Description
Holds the DNS record The authoritative nameserver contains the actual DNS record for the requested domain
Returns the IP address It provides the IP address to the recursor, allowing the client to connect to the right server

Types of DNS queries

Recursive query

In a recursive DNS query, the DNS client (such as a web browser) requires a DNS server (usually a recursive DNS resolver) to respond with either the requested DNS record or an error message if the resolver cannot find the record. The recursive resolver then makes additional requests to find the IP address of the domain name.

Example: When you enter www.example.com in your browser, your computer sends a recursive query to your ISP's DNS resolver. The resolver then sends a query to the root nameserver, TLD nameserver, and authoritative nameserver to get the IP address for www.example.com. Once the resolver has the IP address, it returns it to your computer.

Aspect Description
Client requirement DNS client requires a response with the requested record or an error
DNS server involvement Typically involves a recursive DNS resolver
Additional requests The recursive resolver makes additional requests to find the IP address

Real-life scenario: When you visit a website like https://www.google.com, your web browser sends a recursive DNS query to your configured DNS resolver (usually provided by your ISP or a public DNS service like Google DNS or Cloudflare DNS). The resolver then finds the IP address for www.google.com by making additional requests to the root, TLD, and authoritative nameservers. Once the resolver obtains the IP address, it returns it to your browser, allowing it to connect with the Google server.

Iterative query

In an iterative DNS query, the DNS client allows a DNS server to return the best answer it can. If the queried DNS server does not have a match for the query name, it returns a referral to a DNS server authoritative for a lower level of the domain namespace. The DNS client then queries the referral address, repeating this process until an error or timeout occurs.

Example: If a DNS client sends an iterative query for www.example.com to a DNS server that is not authoritative for example.com, the server might respond with the IP address of the authoritative nameserver for example.com. The client would then query that nameserver to get the IP address for www.example.com.

Aspect Description
Client flexibility DNS client allows a DNS server to return its best answer
Referral process If no match is found, the DNS server returns a referral to another server
Query chain The DNS client follows the referral chain until an error or timeout occurs

Real-life scenario: Iterative queries are often used by DNS servers to communicate with each other. For example, when a recursive resolver receives a query for www.example.com, it starts by sending an iterative query to one of the root nameservers. The root nameserver then responds with a referral to the TLD nameserver for .com. The recursive resolver then sends an iterative query to the .com TLD nameserver, which responds with a referral to the authoritative nameserver for example.com. Finally, the recursive resolver sends an iterative query to the authoritative nameserver, which returns the IP address for www.example.com.

Non-recursive query

A non-recursive query occurs when a DNS server already has the answer to a DNS query in its cache or zone files. This can happen when the DNS server is authoritative for the requested domain or when the record exists in the server's cache from a previous query.

Example: If a recursive DNS resolver has the IP address for www.example.com in its cache due to a previous query, it can respond to a non-recursive query from a client immediately without making additional requests to other DNS servers.

Aspect Description
Server capability DNS server has access to the requested record
Authoritative server The server can be authoritative for the requested domain
Cache utilization The requested record may exist in the server's cache from a previous query

Real-life scenario: Non-recursive queries are commonly used when a DNS server is authoritative for a domain or when it has the requested record in its cache. For instance, if an authoritative nameserver for example.com receives a query for www.example.com, it can respond with the IP address directly without making additional requests. Similarly, if a recursive resolver has recently resolved www.example.com and has the IP address in its cache, it can respond to subsequent queries for the same domain with the cached information until the TTL (Time to Live) expires.

DNS caching

DNS caching is a technique used to temporarily store DNS query results in a location closer to the requesting client. The main purpose of DNS caching is to improve the performance of the DNS resolution process and reduce the load on upstream DNS servers.

How DNS caching works

The main goal of DNS caching is to store often requested DNS records closer to the client, reducing the need for the client to query remote DNS servers. This has several benefits:

  1. Better performance: By caching DNS records, the time needed to resolve a domain name to an IP address is much reduced. This leads to faster loading times for websites and other network resources.

  2. Less bandwidth use: When DNS records are cached locally, the client does not need to send queries over the network to remote DNS servers, reducing the overall bandwidth use.

  3. Less load on upstream servers: DNS caching helps spread the load of DNS queries across multiple levels of cache, reducing the burden on authoritative nameservers and other upstream DNS servers.

Real-life examples of DNS caching benefits:

  • When you visit a frequently accessed website like Facebook or YouTube, your browser and operating system cache the DNS records for those domains. This allows for faster access to those sites on later visits, as the DNS resolution process is shortened.
  • ISPs and large organizations often use caching DNS resolvers to reduce the load on their network infrastructure and improve the browsing experience for their users.

Types of DNS caching

DNS caching can occur at various levels, from the client-side to intermediary resolvers. Here are the main types of DNS caching:

Type Description
Browser DNS caching Modern web browsers have built-in DNS caches. When a user enters a URL, the browser first checks its local cache for the matching DNS record before sending a query to the operating system's DNS resolver. If the record is found in the browser cache, the browser can immediately use the IP address without waiting for a response from an external DNS server.
Operating system (OS) level DNS caching Operating systems maintain a local DNS cache through a component called a stub resolver or DNS client. When an application requests a DNS resolution, the stub resolver first checks its cache for the requested record. If the record is not found, the stub resolver sends a recursive query to the set DNS server, typically provided by the ISP or a third-party DNS service. The stub resolver caches the response from the external DNS server, making it available for future queries.
Resolver DNS caching Caching also occurs at the DNS resolver level, typically managed by ISPs or third-party DNS providers like Google DNS or Cloudflare DNS. When a recursive resolver receives a query from a client, it first checks its local cache for the requested DNS record. If the record is not found, the resolver starts the recursive DNS resolution process, starting with the root nameservers and working its way down to the authoritative nameservers. Once the resolver gets the IP address for the requested domain, it caches the record and returns the result to the client. If the resolver has the nameserver (NS) records for the requested domain cached, it can skip some steps in the DNS resolution process and directly query the authoritative nameservers, further improving the resolution speed.

Real-life scenario of DNS caching in action

Here's a step-by-step example of how DNS caching works in a real-life scenario:

  1. A user types www.example.com into their web browser.
  2. The browser checks its local DNS cache for the IP address associated with www.example.com. If found, the browser uses the cached IP address to connect to the server.
  3. If not found in the browser cache, the browser sends a query to the operating system's stub resolver.
  4. The stub resolver checks its DNS cache for the requested record. If found, it returns the IP address to the browser.
  5. If not found in the stub resolver cache, the query is forwarded to the set recursive resolver (e.g., the ISP's DNS server).
  6. The recursive resolver checks its cache for the requested record. If found, it returns the IP address to the stub resolver, which then forwards it to the browser.
  7. If not found in the recursive resolver cache, the resolver starts the recursive DNS resolution process, caching the result once obtained and returning the IP address to the stub resolver and, ultimately, the browser.

DNS Lookup Process

The DNS lookup process translates a domain name into an IP address. Here are the 8 steps in a typical DNS lookup:

  1. User enters a domain name: When you type a domain name like www.example.com into your web browser, the browser sends a query to a DNS recursive resolver to find the IP address.

    Example: You want to visit www.wikipedia.org and type the domain name into your browser's address bar.

  2. Query sent to DNS recursive resolver: The DNS recursive resolver, often from your Internet service provider or a public DNS service like Google DNS, gets the query from your browser.

    Example: Your browser sends a query to your ISP's DNS recursive resolver, asking for the IP address of www.wikipedia.org.

  3. Resolver queries root nameserver: If the recursive resolver does not have the IP address for www.example.com in its cache, it queries a root nameserver. The root nameserver responds with the address of the Top-Level Domain (TLD) DNS server for the .com domain.

    Example: The ISP's recursive resolver does not have the IP address for www.wikipedia.org in its DNS cache, so it queries a root nameserver. The root nameserver responds with the address of the .org TLD server.

  4. Resolver queries TLD server: The recursive resolver then queries the .com TLD server, asking for the IP address of www.example.com.

    Example: The recursive resolver queries the .org TLD server for the IP address of www.wikipedia.org.

  5. TLD server responds with nameserver IP: The .com TLD server responds with the IP address of the authoritative nameserver for the example.com domain.

    Example: The .org TLD server responds with the IP address of the authoritative nameserver for wikipedia.org.

  6. Resolver queries domain's nameserver: The recursive resolver queries the example.com nameserver for the IP address of www.example.com.

    Example: The recursive resolver queries the wikipedia.org nameserver for the IP address of www.wikipedia.org.

  7. Nameserver returns IP address: The example.com nameserver looks up the IP address for www.example.com in its DNS records and returns it to the recursive resolver.

    Example: The wikipedia.org nameserver finds the IP address for www.wikipedia.org and sends it back to the recursive resolver.

  8. Resolver sends IP address to browser: The recursive resolver caches the IP address for www.example.com and sends it to your web browser.

    Example: The recursive resolver caches the IP address for www.wikipedia.org and returns it to your browser.

Here's a diagram of the 8-step DNS lookup process:

sequenceDiagram participant User participant Browser participant Recursive Resolver participant Root Nameserver participant TLD Nameserver participant Domain Nameserver User->>Browser: Enter www.wikipedia.org Browser->>Recursive Resolver: Query for www.wikipedia.org Recursive Resolver->>Root Nameserver: Query for .org TLD server Root Nameserver->>Recursive Resolver: Return .org TLD server IP Recursive Resolver->>TLD Nameserver: Query for wikipedia.org nameserver TLD Nameserver->>Recursive Resolver: Return wikipedia.org nameserver IP Recursive Resolver->>Domain Nameserver: Query for www.wikipedia.org IP Domain Nameserver->>Recursive Resolver: Return www.wikipedia.org IP Recursive Resolver->>Browser: Return www.wikipedia.org IP

After the DNS Lookup

After the DNS lookup process and the browser has the IP address, two more steps happen:

  1. Browser makes HTTP request: The browser sends an HTTP request to the IP address from the DNS lookup.

    Example: The browser sends an HTTP request to the IP address for www.wikipedia.org to load the webpage.

  2. Server sends webpage: The server at the IP address gets the HTTP request and returns the webpage, which the browser renders for you.

    Example: The server hosting www.wikipedia.org receives the HTTP request and sends back the Wikipedia homepage, which your browser displays.