Domain Name System Series-Understanding DNS
Domain Name System Series-Understanding DNS

Introduction
When you connect to the internet and listen to music, play online games, or browse the web, numerous common protocols are operating behind the scenes to ensure that your computer can actually communicate with these services.
For example, the Internet Protocol, or IP, is in charge of transmitting messages from one computer to another.
These communications are also known as packets, and they always contain a sender, a recipient, and a payload, just like postal parcels.
However, instead of street names and postal codes, the internet utilises IP addresses, which look like this. 197.168.35.87
Without them, computers cannot interact with one another, resulting in the absence of computer networks and the internet.
When you visit medium.com, your computer sends a message to Medium’s IP address, requesting the data required to display the webpage.
“But wait a second,” you say.
“When I want to access Medium, I just type medium.com into my browser.
I don’t require the IP address.
So, how does my computer know the address?”
Thank you for asking!
The History of DNS
The Stanford Research Institute produced a text file named “hosts.txt” in the early days of the internet (ARPANET) to tackle this problem.
This file converted domain names, such as medium.com, into the IP addresses required by computers to interact.
The file was then loaded on all ARPANET computers so that they could “translate” a domain name into an IP address.
However, as the internet grew in popularity, so did the need for domain names.
The tiny staff in charge of the hosts file rapidly became overburdened, so in 1983 a specification was released to automate this work, and DNS, or the “Domain Name System,” was created.
So What is DNS?
DNS is essentially the internet’s phone book, linking domain names like medium.com to IP addresses.
This phonebook is hosted on DNS servers located all around the world.
So, let’s see what happens when you try to go to www.google.com.
To begin, your operating system divides the domain name into numerous pieces, also known as labels separated by dots.
So we have three labels in this case: “www”, “google”, and “com”.
They construct a hierarchical structure that must be read from right to left.
The top-level domain, in this case “com,” is the label on the right.
Then we may argue that “google” is a subdomain of “com,” and “www” is a subdomain of “google.”
The Process:
To find the IP address of google.com, your computer contacts a root name server and asks, “What is the IP address for “www.google.com"?"
Root name servers never provide direct answers; instead, they point you to a server that is more likely to be able to assist you.
That will be the nameserver in charge of the “dot com” top level domain in this case.
Your computer now asks the identical query to the “com” name server, which will very certainly refer you to another name server.
In this situation, it will link you to a Google-hosted name server.
This one will very certainly be able to tell you what IP address is connected to www.google.com.
This technique, together with the domain name hierarchy, makes DNS extremely scalable.
After all, each name server only maintains a limited number of IP addresses.
The “com” name servers, for example, have no knowledge of websites hosted on the “org” domain.
The phonebook analogy applies here as well: my phone number is listed in the Indian phone book but not in the one in the United States.
However, there are two downsides to this.
The Drawbacks:
To begin with, it places a lot of strain on the root name servers because they will be called every time someone attempts to connect to a website or service.
Second, devices must be able to follow a recommendation, which they will get from root servers and perhaps other name servers.
Both of these issues are addressed by “recursive resolvers.”
These are dedicated DNS servers that will handle the whole resolving process.
Instead of contacting numerous name servers, your devices just contact a recursive resolver, which handles everything for them.
The recursive resolver will jump through all of the hoops, making the process much easier for our devices.
They are frequently hosted by internet service providers and, more recently, by businesses like as Google and Cloudflare.
Most home routers do double duty as a recursive resolver.
So, how do our gadgets determine which resolver to use?
By default, they will utilise the one that the network administrator has configured.
In a home network, that is your ISP, and they will most likely install their own resolvers, but you may always use another.
Because some recursive resolvers are quicker than others, switching to a resolver hosted by Google or Cloudflare may provide a modest performance boost.
To improve DNS performance even further, recursive resolvers include a cache that holds the IP address of the most frequently requested domain names.
When you go to google.com on your phone, your router’s recursive resolver looks up Google’s IP address and stores it in its cache for future reference.
If another device on your network attempts to resolve google.com, your router can provide a quick response rather than having to go through the hassle of visiting numerous name servers.
Caching
Caching can significantly improve the speed of DNS requests, but it can also be harmful.
Changes to a domain name’s IP address aren’t instantly mirrored throughout the world since the previous address is still cached in the caches of many recursive resolvers.
To solve this issue, domain owners can specify the length of time an IP address can be stored. This is known as the TTL, or time-to-live, and is measured in seconds.
If a cache entry is older than the specified TTL, the resolver must destroy it and restart the conventional resolving procedure.
However, some recursive resolvers disregard this TTL and store records in their cache for a longer period of time in order to minimise demand.
This approach is inconvenient for website owners who want to alter the IP addresses associated with their domain names.
But that is only a small hiccup.
It is obvious that DNS is a critical component of how we utilise the internet today.
It also offers some interesting alternate use cases.
You can, for example, create a custom DNS server to prevent ads or to protect yourself from malicious sites.
It may appear complex, but you can simply accomplish it by installing PiHole on a Raspberry Pi and connecting it to your home network.
PiHole works as a recursive DNS resolver for all of your devices, as well as when a device needs to resolve advertisements.
For example, if you visit google.com, the PiHole will return a local IP address and effectively prevent the advertisement from loading.
Genius!
Conclusion
So there you have it, a brief introduction of the Domain Name System.
It is a very open system and, without a doubt, a protocol that makes the web accessible and simple to use for everyone.
Domain names are being used to replace difficult-to-remember IP addresses.
That concludes this little post!
Let me know what you think in the comments section below.
If you like the content, please give me ten claps and consider following me.


Comments
There are no comments for this story
Be the first to respond and start the conversation.