Overview and Architecture of DNS (Domain Name System)
A lot goes on behind-the-scenes when you request a certain domain
Global DNS is more than just a server and a database query — it is a well structured system that simplifies the internet for humans by bridging the gap between human-readable domains and computer-readable IP addresses — let’s explore the overview architecture and the process of a domain name lookup!
Introduction to DNS
Every server or computer on the internet has a unique identifier, which we call an IPv4 (32-bit) or an IPv6 (64-bit) IP address. These addresses serve as a "location" of devices on the internet to allow them to communicate with each other. Servers could be hosting some websites, web applications, or API endpoints for various real-world purposes.
With the vast number of servers and websites we have today, each with unique goals and services, it’s impractical for humans to remember and type an IP address, which could look like 193.252.38.42:3000, every time to visit a website.
This is why DNS exists. A Domain Name System provides a mapping of human-readable domains like example.com to computer-readable IP addresses.
In essence, DNS acts as the internet's phonebook, enabling devices to connect and communicate by bridging the gap between user-friendly domain names and machine-friendly IP addresses.
Structure of a domain name
A domain name isn't just a random name for a website; it has a specific structure or hierarchy. Let's examine examples like example.com, example.org, and store.example.com. If we split these domains by the dot (.), each part represents a specific level of the domain name.
Top-level domains (TLD): The last part of these example domains, the words that appear after the final dot (like com and org), are top-level domains. They are at the top of this hierarchy, and there can be countless domains under these top-level domains. Read more.
Second-level domains (SLD): The part of the domain that appears just before the top-level domain (like "example") is called a second-level domain. It usually belongs to a single entity, such as an individual or an organization. Read more.
Sub-domains / Third-level domains: A sub-domain appears before a second-level domain (like www or store) and usually corresponds to an IP address that hosts a specific website or service. These are typically used to organize different services belonging to the same individual or organization. There can be multiple sub-domains under the same SLD. Read more.
Fourth-level domains (rarely used, but exist): In some cases, if there is a need for a highly specific domain, a fourth-level domain can be used, which appears before a third-level domain. For example, in electronics.store.example.com, the word "electronics" is a fourth-level domain.
Walkthrough of DNS resolution process
Whenever you access a website or server using its domain name, several steps are performed, and multiple servers are involved in a DNS lookup to find the IP address of the device hosting the website or service. DNS lookup works by recursively querying servers at each level of a domain, starting from the top-level domain. Let's understand the process using example.com.
Actors
Each actor below is a server handling resolution at different levels of a domain name.
DNS resolver
Recursively makes requests to a series of resolution servers, starting from the Root server, until it finds the IP address of the requested domain.
This process is carried out by ISP (Internet Service Provider) or public DNS servers like Cloudflare or Google DNS server.
DNS resolvers also have their own TTL (time-to-live) cache of domains to increase the lookup speed and will request a server only if the domain cache is not available or if it has expired.
Root server
Top-level domain resolution — Identifies and provides the IP address of TLD server based on top-level domain to DNS resolver.
This server is the starting point for all DNS resolution requests.
It searches its records to find the IP address of the TLD server based on the top-level domain (like .com or .org) in the requested domain. Each top-level domain has its own TLD server and a database of domain records under that top-level domain.
In our example, the root server will return the IP address of the .com TLD server.
TLD server
Second-level domain resolution — Identifies and provides the IP address or domain of the Authoritative DNS server based on the second-level domain to the DNS resolver.
Handles DNS resolution requests for specific top-level domains (like .com or .org).
Each TLD has its own server and a database of records, where each record maps an SLD + TLD to the IP address or domain of the Authoritative DNS server.
Authoritative DNS server / Name server
Final domain resolution — Identifies the IP address of requested domain to DNS resolver.
An Authoritative DNS server is managed by domain registrars or DNS hosting providers like GoDaddy and AWS Route 53. You can also set up your own Name server by configuring DNS software on your server or in the cloud.
It usually holds the records that map domains to IP addresses and can provide the final IP of the requested domain. However, in some cases, this server might respond with a delegation response, providing the IP of another server that can handle the DNS query.
Note on DNS servers and databases Root server
Every domain resolution request from anywhere on the internet starts with the root server, which has a centralized database. However, the root server and its database are replicated across different geographic regions to ensure reliability and reduce latency.
TLD DNS server: Each Top-Level Domain (TLD), like .com or .org, has its own server and database of records for all domains under that specific TLD. Domains are not shared across TLD servers.
Authoritative DNS server / Name server: These operate independently, each with its own separate database of DNS records. For example, a domain registered with GoDaddy’s Name Server can only be resolved through GoDaddy’s Name Server and not by others.
DNS Lookup process
The device sends a request to a domain. If the device cache does not have a valid IP address for the requested domain, the DNS resolver is queried for the domain name resolution (e.g., example.com).
The DNS resolver checks its cache. If the domain isn't cached, it queries the root server. The root server provides the address of the relevant TLD server to the DNS resolver (e.g., .com).
The DNS resolver then makes a request to the address provided by the root server (i.e., TLD server). The TLD server finds and provides the domain/address of the Authoritative DNS server (aka. Name server) to the DNS resolver.
The DNS resolver makes another request to the provided address (i.e., Name server). If the TLD server provided the domain of the Name server (unknown IP address), the DNS resolver will first resolve the domain name of the Name server to get its IP address.
Once the address of the Name server (Authoritative DNS server) is obtained, the DNS resolver queries it for the requested domain. The Name server can either respond with the final IP address of the requested domain or send a delegation response with the domain/address of another name server that can handle this DNS query.
This recursive process continues as the DNS resolver repeatedly queries servers, obtains addresses of servers that can resolve the domain, and uses them to make further requests until it receives a resolution response with the IP address of the requested domain.
DNS registration and Name server
Registering a new domain is quite straightforward: you choose a domain registrar (like GoDaddy, AWS Route53, Domain.com, etc.), provide your details, and select the domain name you want. However, the key part to focus on is when you’re asked to configure the Name Server.
What is a name server?
A name server, also called an Authoritative DNS server or DNS hosting provider, stores the mapping of your domain to the IP address of your server, which hosts your website or service.
This is the same server whose IP address the TLD server provides to the DNS resolver to continue the resolution process.
By default, domain registrars offer their own name servers, but you can choose to use third-party name servers (for example, you can use the AWS Route53 name server when registering a domain with GoDaddy) or even set up your own.
How is a name server registered?
When you choose a name server, your domain registrar communicates with the relevant TLD DNS server (Second-Level Domain server). Now, the TLD server has a record linking your domain (SLD + TLD) to the domain/IP address of your name server.
For example:
You register example.com with a registrar and set the Name Servers to ns1.mydnsprovider.com and ns2.mydnsprovider.com.
The TLD DNS server (the .com server in this case) will now know that example.com can be resolved by your specified Name Servers.
Why is this important?
Whenever someone tries to access your domain, the DNS resolution process works like this:
The request reaches the TLD DNS server (e.g., the .com server).
The TLD DNS server sends the request to your configured Name Servers. These Name Servers will then respond with the IP address of either the server that can continue the domain resolution or the final server that hosts your website or service.
What’s next?
Ever wondered how vital the Root Server is in the Global DNS system? Who manages these systems? How are these servers designed to be reliable and fault tolerant?
In the next part, let’s explore the companies / organizations that manages these systems, the strengths and concerns, and the measures that keep it robust, secure and reliable. Stay tuned!
Thanks for reading it through. Hope the content was valuable! Open to feedbacks. 😃