Domain Name Server (DNS)
- Daljit Singh
- Aug 2, 2024
- 3 min read
So let us now try to understand what Domain Name Server (DNS) is. In the previous article we have read about IP addresses.
Just to give a gist, IP addresses are used to identify a machine on internet. So it's like a address for a machine. But as we know that IP addresses are in numeric format i.e. 192.168.0.1, its very hard for a human to remember IP addresses of different websites.
So, to solve this problem we map IP addresses to human readable URL's. But to make a call to the actual server we need the IP address only.
This brings us to Domain Name System (DNS) which is a hierarchical and decentralized naming system used for translating human-readable domain names to IP addresses.Domain Name Server in action
(Above Image is taken from Geeks For Geeks)
DNS lookup involves the following eight steps:
A client types example.com into a web browser, the query travels to the internet and is received by a DNS Resolver (IP's Recursive Server).
The resolver then recursively queries a Root DNS Server.
The root server responds to the resolver with the address of a Top-Level Domain (TLD).
The resolver then makes a request to the .com TLD.
The TLD server then responds with the address of the Authoritative DNS Server.
Lastly, the recursive resolver sends a query to the Authoritative DNS Server.
The IP address for example.com is then returned to the resolver from the Authoritative Server.
The DNS resolver then responds to the web browser with the IP address of the domain requested initially.
Once the IP address has been resolved, the client should be able to request content from the resolved IP address.
Record Type
DNS records are instructions that live in authoritative DNS servers and provide information about a domain including what IP address is associated with that domain and how to handle requests for that domain.
These records consist of a series of text files written in what is known as DNS syntax. DNS syntax is just a string of characters used as commands that tell the DNS server what to do. All DNS records also have a "TTL", which stands for time-to-live, and indicates how often a DNS server will refresh that record.
There are more record types but for now, let's look at some of the most commonly used ones:
A (Address record): This is the record that holds the IP address of a domain.
AAAA (IP Version 6 Address record): The record that contains the IPv6 address for a domain (as opposed to A records, which stores the IPv4 address).
CNAME (Canonical Name record): Forwards one domain or subdomain to another domain, does NOT provide an IP address.
MX (Mail exchanger record): Directs mail to an email server.
TXT (Text Record): This record lets an admin store text notes in the record. These records are often used for email security.
NS (Name Server records): Stores the name server for a DNS entry.
SOA (Start of Authority): Stores admin information about a domain.
SRV (Service Location record): Specifies a port for specific services.
PTR (Reverse-lookup Pointer record): Provides a domain name in reverse lookups.
CERT (Certificate record): Stores public key certificates.
Sub domains
A subdomain is an extension of our primary domain name, often used to logically divide a website into distinct sections. It is possible to establish multiple subdomains or child domains under the main domain.
For instance, consider blog.example.com, where blog represents the subdomain, example is the main domain, and .com is the top-level domain (TLD). Other similar illustrations include support.example.com or careers.example.com.
DNS Caching
A DNS cache (sometimes called a DNS resolver cache) is a temporary database, maintained by a computer's operating system, that contains records of all the recent visits and attempted visits to websites and other internet domains. In other words, a DNS cache is just a memory of recent DNS lookups that our computer can quickly refer to when it's trying to figure out how to load a website.
The Domain Name System implements a time-to-live (TTL) on every DNS record. TTL specifies the number of seconds the record can be cached by a DNS client or server. When the record is stored in a cache, whatever TTL value came with it gets stored as well. The server continues to update the TTL of the record stored in the cache, counting down every second. When it hits zero, the record is deleted or purged from the cache. At that point, if a query for that record is received, the DNS server has to start the resolution process.
Enjoyed the article? Don't forget to leave a like, drop a comment, and share it on social media to spread the word!
Follow us on instagram @seasonalcoder to get regular updates on System design, DSA and more.












Comments