Table of contents
Have you ever wondered how typing a simple web address like 'google.com' magically takes you to the right website? The answer lies in the unsung hero of the internet: DNS."
So What is DNS or Domain name system? Let’s understand by an example.
We all have our residential address which refers to a point that combines latitude and longitude on the earth. Can we remember all the addresses using latitudes and longitudes? So to make it easy to understand for humans we made a System of address for each latitude and longitude.
Similarly, we have so many websites with different IP addresses(latitude and longitude) for them. So that we can locate the server where it has been hosted.
So this magic is done by a system known as the Domain Name System (DNS).
What is DNS?
A domain name system is a system in which we map a website address string to the IP address of that website on a server. It converts human-readable web addresses (domain names) of the websites into IP addresses that computers can understand and use. They translate what a user types into a browser into something the machine can use to find a webpage. A fancy term for this process is called DNS resolution.
Domain name hierarchy.
Top-level domain: The top-level domain is the last part of the domain name – .com and .org are two common top-level domains.
Second-level domain: The second-level domain is the main website name before the top-level domain.
Subdomains: Subdomains are prefixed before the second-level domain to divide sections of a website.
How does DNS work?
When we type a web address on the web browser here’s how it finds the IP of the website.
Your computer first checks its own DNS cache to see if it already has a record of the domain name and IP address. This local cache stores previously visited domains and IPs to speed up repeat lookups.
If the requested domain is not in the cache, your computer sends a DNS query to a recursive resolver, which may be provided by your Internet Service Provider or a public DNS service.
The recursive resolver then contacts a DNS root nameserver, which directs it to the Top-Level Domain (TLD) nameserver for that domain. For example, .com and .org domains are managed by different TLD nameservers.
The TLD nameserver then directs the recursive resolver to the authoritative nameserver for the specific domain being requested. Each domain name has its own authoritative nameserver with records for that domain.
The authoritative nameserver returns the IP address for the requested domain back to the recursive resolver.
The recursive resolver passes the IP address back to the original computer that made the request.
Your computer can now connect to the web server using the IP address.
Doesn’t it seem to be a boring theory? Let me illustrate this in a diagram.
As we've explored how DNS functions, you may now be wondering: What types of DNS records are there?
DNS Records
DNS servers store records. When a DNS query is sent by a device, it receives a response from those records with the help of DNS servers and resolvers.
Type of DNS records
DNS Record | Description |
A | Maps domain names to IPv4 addresses |
AAAA | Maps domain names to IPv6 addresses |
CNAME | Redirects a domain to a different domain |
PTR | Resolves IPv4 or IPv6 addresses to domain names |
NS | Provides a list of the authoritative name servers responsible for the domain |
MX | Provides the domain names of mail servers that receive emails on behalf of a domain |
SOA | Provides important details about a DNS zone; required for every DNS zone |
TXT | Provides any type of descriptive information in text format |
Well this is end to our article hope you enjoyed it :)