What is DNS?
It stands for Domain Name System. That’s the full name, but what does it mean? It is a system that allows people to connect to different websites. The system matches the human-readable names (domain names) with unique ID of the server where the website files are stored.
You are confused, aren’t you?
Okay, let me put it this way – consider the DNS as the phonebook of the internet. What do you see in a phonebook?
You can see people’s names and their corresponding phone numbers.
Now, replace the names with the domain names, and the phone numbers with IP addresses, which are the corresponding identifiers of those domain names.
What you get is a system similar to a phonebook. That’s why I said that consider it as the phonebook of the internet.
When you enter a domain name (for example: Cloudzat.com) in your web browser, the browser doesn’t go about looking for the name that you have put it. Instead, it looks up the IP address connecting the name to the physical server where the website files sit.
Clear so far?
Good!
Let’s proceed to understand how the system works.
How does DNS work?
Did you know that internet is a gigantic network of computers? These computers communicate with each other. Since, there are too many computers, how does one computer identify other.
This is where the concept of IP address comes in.
Each computer in the network is assigned a unique IP address. No two computers will have the same IP address.
The IP address is a string of numbers. Each number in the string is separated by period.
An IP address looks like this: 149.28.157.32
Note: This is just random string of numbers that I thought of while writing this blurb. It may accidentally match with an IP address, and I am sorry if it does.
But do you see the problem?
Can you memorize this string of numbers with ease?
How about memorizing multiple such strings?
What would happen if you had to type a particular string of numbers in your web browser everytime you want to visit a website.
That’s completely illogical and irrational.
Another problem is that such a string of numbers will never tell you anything about the website you intend to visit.
For instance, 149.28.157.32 may refer to a website that gives information about dogs. It may be a website that contains adult material, or it may be a website that gives out religious information.
How on Earth are you supposed to understand what type of website you are trying to visit just by looking at the string of numbers?
This is where domain names come it.
Domain names were invented to allow users to use alphabets to create an easy to remember name for their websites.
A person intending to visit the website can easily remember the domain name compared to the string of numbers.
Also, the domain name can give a good idea of what type of website to expect. For instance, the domain name factslides.com easily tells you that you can expect to see slides gives facts on various things. And indeed, that is what it does!
Now comes the Domain Name System or the DNS.
The Domain Name System will take a domain name and translate it into IP address and point your web browser to the right direction where the website corresponding to the domain name is located.
This is where the concept of DNS record comes in.
A domain name and its matching or corresponding IP address are together known as the DNS Record.
The four easy steps to understand how DNS works
Here is how the entire process works:
Step 1: You use your browser.
- You type the domain name of the website you want to visit in the URL bar of your web browser. For instance, you type in Cloudzat.com and hit the enter button your keyboard.
- The browser will check whether you have visited the website earlier or not. It looks for the information in the DNS cache of your computer.
- If the browser finds the information in the DNS cache, it will skip the DNS lookup steps and take you directly to Cloudzat.com.
- If no records are available in the DNS cache of your computer, the browser then moves on with DNS lookup.
Step 2: Browser queries local DNS server
- If the browser fails to find any DNS record in the DNS cache of your computer, it will then send your query to the local DNS server, which is essentially your ISP or Internet Service Provider’s server. This local DNS server also goes by the name ‘resolving server.’
- If the browser finds the DNS record in the resolving server, it will skip the next step and take you directly to Cloudzat.com.
- If the browser fails to get the information from the resolving server, it will move on with the DNS lookup.
Step 3: Browser queries the root nameserver
- In case the browser doesn’t find any information with the resolving server, it will then forward your query to the root nameservers. Root nameservers are designated servers across the world with a specific job – storing DNS data to ensure the whole DNS system works properly.
- If the website you are trying to access exists, the DNS record will exist in the root nameservers. The browser will get the data from there.
Step 4: Browser connects you to the website
- As I said, if the website exists, the browser will find the data in the root nameservers. Once it gets the data, the browser will open a connection to the server where the website you are trying to access is stored.
- The server will respond back and send the website files to the browser. The browser will then display the website in front of you.
You can sum up the entire process using the image below (follow the color code for a clear understanding of the image):
Okay, now that you have understood how DNS works, there are still a few questions that I need to answer, and you need to know.
Shall we start?
General FAQ
The internet is made of a network of computers. These computers are known as servers. A server typically stores websites and serves them to other computers across the world.
A Name Server (or a Nameserver), on the other hand, is a type of computer that keeps all the DNS records of all domain names that exist in the world today. A Nameserver will never store websites.
The job of a Nameserver is to provide the DNS record of the domain to anyone who is requesting it.
Hosting providers and domain name providers typically manage the Nameservers. For instance, if you are using DigitalOcean for hosting your website, the Nameservers that DigitalOcean uses for store the DNS records are:
NS1.DITIGALOCEAN.COM
NS2.DIGITALOCEAN.COM
NS3.DIGITALOCEAN.COM
Typically, there has to be at least two Nameservers for one domain. More than that is fine.
The first Nameserver is known as primary while the other one is called secondary. If the primary Nameserver fails to provide the DNS record for some reason, the secondary Nameserver comes in provides the information, that is, resolves the domain name.
There are some providers that will allow you to use your own private Nameservers. Unfortunately, setting up private Nameservers is a multi-step process and requires registering them with your domain registrar.
Setting up private Nameservers is a complex process, and if you want to get them, you should ask for assistance from your domain name registrar for registration and setup guide. They will help you with the process.
Private Nameservers look something like this:
NS1.YOURDOMAIN.COM
NS2.YOURDOMAIN.COM
NS3.YOURDOMAIN.COM
Where YOURDOMAIN.COM is your actual domain name.
CNAME is a type of DNS record. It stands for Canonical Name. It is used for pointing one domain name to another domain name instead of IP address.
Suppose you registered two domains – example.com and examples.com.
You want visitors of examples.com to reach example.com.
In a situation like that, you use CNAME to ensure that all visitors of examples.com are routed to example.com.
Often people use CNAME to route people from non-www version of the website to the www version of the site.
One of the primary uses of CNAME is when you want to use professionally branded emails like Gmail or Outlook with your domain.
MX record is yet another type of DNS record and it stands for Mail Exchanger record. It defines a mail server to handle emails from a specific domain. For instance, you may make Gmail’s mail servers to handle emails received by your domain.
While it is a common method for people to use contact forms and use the mail servers of their hosting providers for communication, I usually recommend people to use Gmail or Outlook’s mail servers to handle emails. This reduces server load and increases reliability.
Another type of DNS record, the TXT record is used for adding a layer of trust to your email server, and thereby increases its deliverability. This means that if you are using a TXT record, the chance of your outgoing emails landing in the spam folder decreases.
By adding a TXT record, you may add both SPF or Sender Policy Framework, and DKIM or Domain Key Identified Mail records. Both add an encrypted key to all your outgoing emails.
Suppose a visitor visits your website from one region in the world. The local ISP-managed Nameservers closest to that region will cache the DNS records so that in the event of any repeated requests for your website from the same region, the website is served quickly.
Unfortunately, resolving DNS still takes time. Though usually the time taken is in milliseconds, larger business do not like that.
For smaller businesses, such milliseconds don’t really matter and they are happy with what they have and resort to using the DNS offered by their hosting provider or domain name registrar.
There are free DNS service providers like CloudFlare that offers a very fast DNS but with very limited firewall protection.
If you want enhanced security, geo traffic redirection, 100% uptime, faster lookup speeds, etc., opting for a paid DNS is much better. One of the finest premium DNS service providers is DNSMadeEasy.
Conclusion
This article on what is DNS and how does DNS work is an overly simplified article designed for the basic understanding of DNS and its modus operandi. In reality, the whole thing is very complex.
Usually, you don’t have to worry about all these things. You can follow the simple instructions provided by your hosting provider or your domain name registrar and you should be good to go.
If you do intend to try out new things like setting up your own private nameservers or using a premium DNS, try them on a testing site to ensure that your production site doesn’t get hurt due to unexpected errors caused by mistakes on your part while implementing them.