Pages

Friday, June 9, 2017

How the Domain Name System (DNS) works

Example HTML page
1. Client enters ‘www.example.com’ internet address. Client computer needs the IP address translation of ‘example.com’ and first checks its own DNS cache for this information. If this is the first time using this website or the cache has been cleared it cannot find the IP address here.

2. The client computer (or “query”?) is then redirected to the Internet Service Provider’s (ISP’s) DNS Server. The ISP’s DNS server checks its own cache but it will not be there if the site has not been accessed before.

3. The ISP’s DNS server redirects the query to the Root DNS Server. Every DNS server has a file that contains a list of all of the root DNS servers. Totally there are 13 root DNS servers.

4. The root DNS server maintains information about where a top-level (like .com, .in) DNS server is located and returns this information to the ISP’s DNS Server.

5. The ISP’s DNS server redirects the query to a top-level (.com) DNS server.

6. The top-level (.com) DNS server knows the IP address of the DNS server(Authoritative DNS server) for the example.com domain and returns that information to the ISP’s DNS server.

7. The ISP’s DNS server redirects the query to the actual authoritative DNS server for the example.com domain.

8. The DNS server for www.example.com returns the IP address of the host of www.example.com to the ISP’s DNS server.

9. Lastly, the ISP’s DNS server sends the IP address to the client computer so the client can access www.example.com

When your browser connects to a website say example.com, the browser first queries your local DNS server to get the IP address of example.com.

If the local DNS server doesn't have the A record of example.com, it will query one of the root DNS servers.

The root DNS server will say: I don't have the A record but I know the top-level domain DNS server which is responsible for .com domains.

Then your local DNS server query the top-level domain DNS server which is responsible for .com domains. The TLD DNS server will respond: I don't know either but I know which DNS 
server is authoritative for example.com.

So your local DNS server queries the authoritative DNS server. Because the actual DNS record is stored on that authoritative DNS server, so it will give your local DNS server an answer.

First you have to understand how DNS system works. DNS system can be divided into three tiers. They are:

a) root DNS servers
b) top-level domain DNS servers
c) authoritative DNS servers
d) Local DNS server (Which Will be IP of ISP) whose IP address is specified on your operating system.

When your browser connects to a website say example.com, the browser first queries your local DNS server to get the IP address of example.com.

If the local DNS server doesn't have the A record of example.com, it will query one of the root DNS servers.

The root DNS server will say: I don't have the A record but I know the top-level domain DNS server which is responsible for .com domains.

Then your local DNS server query the top-level domain DNS server which is responsible for .com domains. The TLD DNS server will respond: I don't know either but I know which DNS 
server is authoritative for example.com.

So your local DNS server queries the authoritative DNS server. Because the actual DNS record is stored on that authoritative DNS server, so it will give your local DNS server an answer.

Then this query result is cached on your local DNS server but it can be outdated. When the TTL time has expired, your local DNS server will update the query result from the authoritative DNS server. Whenever you query a DNS record on your local DNS server, it returns a non-authoritative (unofficial) answer. If you want an authoritative answer, you must explicitly specify the authoritative DNS server when you use nslookup or other utilities. I think a local DNS server should be called caching DNS server.


No comments:

Post a Comment