Introduction to DNS?

Introduction to DNS?

A brief introduction to DNS and its working mechanisms.

Intuition:

In Nepal, in our board examinations, we are not allowed to write our names on the exam paper.

We are given a unique roll number and that is what we enter in our paper.

So, the examiner does not know whose paper he is looking into.

But, after the paper is reviewed, marks assigned and when finally we receive our mark-sheet, it contains both our name and roll number.

What has happened here is the examination control division has mapped the roll number with the correct student name while creating the mark sheet.

DNS(Domain Name System) work in a similar way.

Each device in the network has an unique roll number they are identified with, and they are called ip addresses. And, the devices in the network identify and communicate with each other with the help of ip addresses.

For example, one of the ip addresses of google search engine server is 142.251.161.147.

So, if we need to visit google, we could just enter the above ip address.

But, as long as you are not the rain-man, it is pretty difficult to remember ip addresses.

Human beings find it much easier to remember a text than number.

And, remembering google.com is much easier than to remember a random ip.

But, how will the internet know that google.com should be redirected to142.251.161.147?

It is where DNS servers come into play.

DNS Infrastructure:

Imagine, a user enters, google.com in his browser.

The browser first checks whether or not the ip for the domain name is present in the browser cache. If yes, it is returned.

Otherwise, it will check the OS cache. If the ip is found, it returns it. Else, the request is forwarded to DNS Infrastructure.

DNS infrastructure has mainly 4 types of servers.

  1. DNS resolver:

    DNS resolver is basically the ISP(Internet Service Provider).

    Here, it is checked whether or not the ip is present in the ISP cache.

    If yes, the ip is returned. Otherwise, the request is forwarded to the DNS Root Server.

  2. Root Server:

    Root servers take the query from DNS resolver, but they have no idea what is the corresponding ip address for the given domain name.

    What they do is check the domain of the query (i.e. .net, .com, .org and so on).

    Based on the domain, it directs the DNS resolver to the correct Top Level Domain Server responsible, let's say, .com.

  3. Top Level Domain Server:

    Now, the request reaches the domain server that handles the .com domain in our case.

    But, it too does not know the exact ip address.

    But, it exactly knows which Authoritative Name Server has that information.

    So, it provides the address of the Authoritative Name Server and bid DNS resolver good luck !

  4. Authoritative Name Server:

    Now, DNS resolver will contact the Name Server as per the address given my TLDS.

    And, the Name Server will look into its data entries and find the appropriate domain name -> Ip mapping.

    Then, it returns the desired IP address.

Then the DNS resolver will return the ip address to the browser, which will turn access the domain with the given ip address.

The below diagram shows the scenarios discussed above.

Fig. How DNS works?

At the end, let me tell you an interesting thing related to caching in DNS.

Try entering nslookup www.google.com the following command in your terminal.

Did you notice Non-authoritative answer in the output?

It means that the ip address was not returned by one of the Authoritative Servers but was returned from one of the caching layers !

Hope you enjoyed the article. If you did, please follow me on LinkedIn for more articles on system design.