Day 7 — CS Fundamentals December — About Networking — DNS Working

Yashvardhan Kukreja
5 min readDec 8, 2019

Remember, computers only understand numbers, not names. But when you type in a URL in your browser, like google.com, you get google’s webpage.

So, what exactly is happening?

Now, google.com is being translated to its IP address for getting its webpage.

But how does this exactly happen?

Is there a phonebook-like thing to lookup website names and IP address? Is there guy telling computers about IP address?

Well, this article is going to explain about how “exactly” a domain name is converted to its IP address.

Let’s dive in!

Introduction

So, as I said, computers understand only numbers and not names. So, even in a network, computers connect each other through IP address (number) but do you remember the last time you typed an IP address in the browser to get a website/webpage?

No, right!

Getting a website/webpage is, basically, your computer connecting and talking and requesting a webpage from some other computer in the internet.

We all enter domain names like, github.com, google.com, etc. and behind the scenes, the browser does some black magic to get the corresponding IP address and then, use that IP address to connect and get the required website.

So, the magician performing that black magic is DNS i.e. Domain Name System.

What is Domain Name System?

Domain Name System is kind of like a database where the human-readable domain names, like google.com, can be looked into and the corresponding IP address of the domain name can be retrieved and hence, further used to get the respective website and webpage.

Very Basic Flow

  1. User enters domain name, say google.com in the browser.
  2. The browser asks DNS about the IP address of google.com
  3. DNS gives it the IP address.
  4. Browser uses that IP address to communicate with google.com server and get the required website/webpage.

Now, let’s talk about the complete flow

Step 1). User enters domain name, say google.com

Step 2). The browser first checks in its cache, if already the IP address for google.com is saved in there.

If google.com was searched before, the browser would have saved its IP address in the cache, so as to save time in the future for looking up the IP address for google.com in the cache without even touching DNS.

Step 3). Say, the browser cache did not have it. So, the browser then, sends it to the Resolver Server. The Resolver Server is, basically, your ISP (Internet Service Provider).

Step 4). The Resolver Server then, checks in its cache if IP address for google.com exists or not.

Step 5). Let’s say, it wasn’t in the cache of Resolver Server as well.

Step 6). Then, the Resolver Server passes the domain name to the Root Server.

Root server is like the top-hierarchical server in DNS. Its purpose to tell Resolver Server to where to go next to find the IP address, that’s it.

There are only 13 root servers in the world, strategically placed so as to reduce latency for anyone accessing it in the world.

Step 7). So, the root server tells the location (IP address) of Top-Level Domain Server for .com

Top-Level Domain means .com, .org, .in, .tech, etc. So, the root server looks into domain name i.e. google.com and says,

“Dude, this is a .com website which means that the Top-Level Domain Server for .com would be able to tell you about the IP address of google.com. Have this IP address to it (top-level domain server) and go there!”

Step 8). Then, the resolver server on receiving the IP address to the top-level domain server for .com, contacts it and asks,

“Bro! Do you know the IP address for google.com?”

The top-level domain doesn’t know about the IP address so, it will say,

“Sorry man! I don’t know the IP address for google.com. But I can give you the location (IP address) to the Nameserver which stores the IP for google.com. You can communicate and get it from there, cool?”

Step 9). Then, the resolver server, on getting the IP address to the Nameserver, communicates with that Nameserver and asks about IP address to google.com and Nameserver gives it the IP address.

Phew!

By the way, Nameservers are servers which are responsible for knowing everything about domain names, which also involves IP address.

Considering there are billions of domain names in the world, there are numerous nameservers in the world and the resolver server gets to the right nameserver through root server and then, top-level domain server.

Step 10). Then, the resolver server finally receives the IP address to google.com

Step 11). Then, before anything, it first saves it in its cache so that the next time, it doesn’t have to go through this entire process for finding the IP address of google.com again.

Step 12). After saving in the cache, it sends the IP to the browser.

Step 13). The browser, on receiving the IP, saves it in its own local cache so that the next time, it doesn’t have to even communicate with resolver server for finding the IP address of google.com again.

Step 14). And after saving the IP in the local cache, it uses that IP address to communicate with Google server and get the required website/webpage.

Phew! Well, that was tiring!

That’s it!

Thanks for reaching till here :)

I hope you understood the article and if you liked it do give it some claps :D

Find me on

LinkedInhttps://www.linkedin.com/in/yashvardhan-kukreja-607b24142/

GitHubhttps://www.github.com/yashvardhan-kukreja

Email — yash.kukreja.98@gmail.com

Adios!

--

--

Yashvardhan Kukreja

Software Engineer @ Red Hat | Masters @ University of Waterloo | Contributing to Openshift Backend and cloud-native OSS