What is DNS?

In one line – It is Internet’s phone directory. DNS is what translates/resolves domain names (like Google.com) to an IP Address.

That is, it maps domain names to IP addresses. Without DNS, you’d have to remember IP address of every single website.

Source: https://www.appneta.com/

Ok so how does it work? Let’s understand with the help of an example:

  1. You type in Google.com in your browser and hit enter.
  2. Your computer then tries to find an IP address of Google.com.
    1. It checks the browser cache first.
    2. If not found, it checks your system cache.
    3. If not found, it’ll check your router’s cache.
    4. Still not found? It’ll send that request to your ISP (internet service provider).
      1. Your ISP will most likely have it but if it doesn’t have a record, your request now will be sent to one of the 13 root servers. (Note: there aren’t 13 physical servers but hundreds of servers across the world maintained by 13 entities).
      2. The root server gives an IP address of the TLD (top level domain) server. In case of Google.com, the TLD is .com and so your ISP gets an IP address of the .com TLD server.
      3. Your ISP now asks the TLD server for Google.com’s IP. The TLD server returns an IP of the authoritative DNS server.
      4. Finally ISP contacts the authoritative DNS server and gets Google.com’s IP address.
    5. Once your ISP has the IP address of Google.com, it’ll send it back to your router. Your router sends it back to your system and your system gives it to your browser. At each step, a copy of this record will be cached/stored.
  3. Your browser then makes a request to that IP (and starts to establish TCP connection, SSL/TLS connection, request web pages, etc).

Note: Your ISP server acted as a recursor or recursive resolver. That is, even if it didn’t have the answer, it recursively found the answer.

Troubleshooting DNS Issues

Let’s say you try to load a website in Google Chrome and it doesn’t work. But it works fine on your mobile device. This could be a DNS related issue.

The easiest and fastest way to test if you have a DNS problem, is to directly enter the IP address in the browser. Of course you will need to know the IP before hand so this isn’t super helpful.

The other option is to try using different DNS servers. For example, you can try Google’s DNS 8.8.8.8 or CloudFlare’s DNS 1.1.1.1.

If you’re using Mac, you can configure DNS servers under Network Preferences. You can also configure DNS settings on your router. If you’re on Windows or other OS, you can do a quick Google search to find OS specific instructions.

I hope this post gives you some insight about how DNS works. If you have any questions or thoughts, please leave them in the comments below. Thanks.