How Dns Works

How Dns Works

Β·

2 min read

Table of contents

No heading

No headings in the article.

DNS.jpeg

𝐃𝐍𝐒 π‘π„π’πŽπ‹π”π“πˆπŽπ "Mostly about getting an IP for a domain name"

Steps involved in the lookup....

⭐️ A user types 'example.com’ into a web browser.

⭐️ The browser parses the information contained in the URL. This includes the protocol (β€œhttps”), the domain name (β€œexample.com”) and the resource (β€œ/”). In this case, there isn’t anything after the β€œ.com” to indicate a specific resource.Browser tries to find the IP address.

⭐️ Browser cache: The browser caches DNS records for some time. Interestingly, the OS does not tell the browser the time-to-live for each DNS record, and so the browser caches them for a fixed duration (varies between browsers, 2 – 30 minutes).

⭐️ OS cache: If the browser cache does not contain the desired record, the browser makes a system call (getaddrinfo in Linux). The OS has its own cache.

⭐️ Router cache: The request continues on to your router, which typically has its own DNS cache.

⭐️ ISP DNS cache: The next place checked is the cache ISP’s DNS server has.

⭐️ The resolver mostly your ISP then queries a DNS root nameserver (.).

⭐️ The root server then responds to the resolver with the address of a Top Level Domain (TLD) DNS server (such as .com or .net), which stores the information for its domains. When searching for example.com, our request is pointed toward the .com TLD.

⭐️ The resolver then makes a request to the .com TLD.

⭐️ The TLD server then responds with the IP address of the domain’s nameserver, example.com.

⭐️ Lastly, the recursive resolver sends a query to the domain’s nameserver.

⭐️ The IP address(or rather addresses) for example.com is then returned to the resolver from the nameserver. Note : (DNS can return the list of IP addresses for the same domain name. When a web-browser requests a web-site, it will try these IP addresses one-by-one, until it gets a response.)

⭐️ The DNS resolver then responds to the web browser with the IP address of the domain requested initially. The DNS lookup have returned the IP address(or addresses) for example.com, the browser is able to make the request for the web page:

⭐️ The browser makes a HTTP request to the IP address(Choose an IP from the set of Ip's returned).

⭐️ The server at that IP returns the webpage to be rendered in the browser.

Note: DNS servers mostly run on port 53.

Tools to get the IP address from the domain name in your command line...

  1. nslookup Usage: ➜ nslookup google.com -- Output Server: 192.168.1.1 Address: 192.168.1.1#53

Non-authoritative answer: Name: google.com Address: 142.250.195.46

  1. dig Usage: ➜ dig facebook.com

Thanks for reading. Please follow for more...

Β