Understanding DNS: What It Is and How It Works

Understanding DNS: What It Is and How It Works

Do you memorize facebook.com better or its IP address 69.63.176.13 ? 😕

I know its a little bit difficult to remember the IP’s of websites, that’s why we have different domain names which makes easier for us to remember them.

So, What actually is Domain Name System ?

Let’s deep dive into the basics of URL

  1. Protocol - The protocol or scheme part of the URL and indicates the set of rules that will decide the transmission and exchange of data.

  2. Subdomain - The subdomain is used to separate different sections of the website as it specifies the type of resource to be delivered to the client**.**

  3. Domain - Domain name specifies the organization or entity that the URL belongs to.

  4. Top-level domain - The TLD (top-level domain) indicates the type of organization the website is registered to.

  5. Subfolder - Subfolder/Path specifies the exact location of the web page, file, or any resource that the user wants access to.

  6. Parameters/Query string - The query string specifies the parameters of the data that is being queried from a website’s database. Each query string is made up of a parameter and a value joined by the equals (=) sign.

Now that you have an understanding of different parts of a URL, let us now get back into DNS.

The Domain Name System (DNS) is the phonebook of the Internet. Humans access information online through domain names, like facebook.com or chaicode.com. Web browsers interact through Internet Protocol (IP) addresses. DNS translates domain names to IP addresses so browsers can load Internet resources.

⭐ In simple language, DNS simply converts the domain name into its corresponding IP address

IP address

If you want to send a love letter to your girlfriend you need to know her address. In the same way if you want to send any data across the internet we need IP addresses. IP stands for Internet Protocol. Its nothing but a unique id which is assigned to every device which is connected to the Internet🌐. It serves as an identifier that allows devices to send and receive data over the network, ensuring that this data reaches the correct destination.

There are two types of IP addresses :

  1. IPV4 - It consists of four sets of numbers separated by dots. For example, 192.158.1.38. Each set of numbers can range from 0 to 255. This format can support over 4 billion unique addresses.

  2. IPV6 - IPv6 addresses were created to deal with the shortage of IPv4 addresses. They use 128 bits instead of 32, offering a vastly greater number of possible addresses. These addresses are expressed as eight groups of four hexadecimal digits, each group representing 16 bits. The groups are separated by colons.

    Example - 2001:0db8:85a3:0000:0000:8a2e:0370:7334

4 different types of DNS servers

  1. DNS recursor - The DNS recursor is a server designed to receive queries from web browsers. It is responsible for making additional requests in order to satisfy the client’s DNS query.

  2. Root nameserver - The root server is the first step in translating (resolving) human readable host names into IP addresses. It answers requests for records in the root zone of the Domain Name System (DNS).

  3. TLD Nameserver - This nameserver is the next step in the search for a specific IP address, and it hosts the last portion of a hostname (In chaicode.com, the TLD server is “com”).

  4. Authoritative nameserver - The authoritative nameserver is the last stop in the nameserver query. If the authoritative name server has access to the requested record, it will return the IP address for the requested hostname back to the DNS Recursor that made the initial request.

Steps involved in DNS lookup

Step 1 - A user types “chaicode.com“ in the browser, this request travels in the internet and first is received by a DNS resolver.

Step 2 - The DNS resolver then checks the IP in the local cache, if it is present then it is returned from there directly.

Step 3 - If the IP is not present in the cache, the query is then transferred to DNS root server.

Step 4 - The root server then returns the IP of the top level domain (TLD) server (example .com, .net, .org etc.) .

Step 5 - The resolver then makes a request to Top level domain server.

Step 6 - The TLD server then return the IP address of the domain’s nameserver chaicode.com .

Step 7 - Lastly, the resolver sends a query to the domain’s nameserver.

Step 8 - The IP address for chaicode.com is then returned to the resolver from the nameserver.

Step 9 - The DNS resolver then returns the web browser with the IP address of the domain requested.

Step 10 - The browser then makes a HTTP request to the IP address returned by the DNS.

Step 11 - Finally the webpage is rendered at the browser.

Conclusion 🚀

In conclusion, the Domain Name System (DNS) is an essential part of the application layer in networking . It acts like the internet’s directory, translating human-friendly domain names into numerical IP addresses that the computer use to communicate. Without DNS, navigating the internet would be much more difficult, as we’d need to remember complex IP addresses for every website. DNS makes the internet user-friendly and efficient, allowing us to easily access websites and online services by using simple, memorable names.