What is DNS?
DNS stands for domain name system, The Domain Name System (DNS) translates Internet domain and host names to IP addresses and vice versa.
DNS automatically converts between the names we type in our Web browser address bar to the IP addresses of Web servers hosting those sites.
Why is DNS important?
When we enter the URL in the browser’s address bar e.g. www.google.com, our computer uses DNS to retrieve the website’s IP address of 18.104.22.168. Without DNS, you would only be able to visit Google home page site, by visiting its IP address directly, such as http:// 22.214.171.124
How does DNS work?
Every time when we visit a domain such as www.google.com, computer follows a series of steps to turn human-readable web address into a machine-readable IP address.
- Step 1: Request information
- Step 2: Asking the recursive DNS servers
- Step 3: Asking the root nameservers
- Step 4: Asking the TLD nameservers
- Step 5: Asking the authoritative DNS servers
- Step 6: Retrieve the record
- Step 7: Receive the answer
Step 1: Request information
The process of first step begins when we type the URL in the address bar of the browser e.g www.google.com. The first place our computer looks into its local DNS cache, which stores information that your computer has recently retrieved.
If our computer doesn’t already know the answer, it needs to perform a DNS query to find out.
Step 2: Asking the recursive DNS servers
If the information is not stored locally, our computer queries your ISP’s recursive DNS servers. These specialized computers perform the legwork of a DNS query on your behalf. Recursive servers have their own caches, so the process usually ends here and the information is returned to the user.
Step 3: Asking the root nameservers
If the recursive servers don’t have the answer, they query the root nameservers. A nameserver is a computer that answers questions about domain names, such as IP addresses. The thirteen root nameservers act as a kind of telephone switchboard for DNS. They don’t know the answer, but they can direct our query to someone that knows where to find it.
Step 4: Asking the TLD nameservers
The root nameservers will look at the domain name from right to left
The root nameservers will look at the first part of our request, reading from right to left www.google.com and direct our query to the Top-Level Domain (TLD) nameservers for .com. Each TLD, such as .com, .org, and .us, have their own set of nameservers, which act like a receptionist for each TLD. These servers don’t have the information we need, but they can refer us directly to the servers that do have the information.
Step 5: Asking the authoritative DNS servers
The TLD nameservers review the next part of our request — www.google.com — and direct our query to the nameservers responsible for this specific domain. These authoritative nameservers are responsible for knowing all the information about a specific domain, which are stored in DNS records. There are many types of records, which each contain a different kind of information. In this example, we want to know the IP address for www.googledns.com, so we ask the authoritative nameserver for the Address Record (A).
Step 6: Retrieve the record
The recursive server retrieves the A record for google.com from the authoritative nameservers and stores the record in its local cache. If anyone else requests the host record for google.com, the recursive servers will already have the answer and will not need to go through the lookup process again. All records have a time-to-live value, which is like an expiration date. After a while, the recursive server will need to ask for a new copy of the record to make sure the information doesn’t become out-of-date.
Step 7: Receive the answer
Armed with the answer, recursive server returns the A record back to your computer. Your computer stores the record in its cache, reads the IP address from the record, then passes this information to your browser. The browser then opens a connection to the webserver and receives the website.
This entire process, from start to finish, takes only milliseconds to complete.