What happens when we type google.com

17 July 2020

Image Source :  spectrum.ieee.org

There is always a mystery about what happens in background when we do a simple task by typing google.com in address bar of browser. There are lot of things happening behind that address that we are not aware of , lets demystify this process and get a good understanding about this topic.

What is URL?

URL stands for Uniform Resource Locator which uniquely identifies each resource in the internet, URL consists of different parts including protocol, host name, port, query string etc.

https://www.google.com/search?query=

This is a typical example of an URL , it consists of following

  1. http: protocol to use for communications
  2. www.google.com: host name to which our browser will communicate to.
  3. search?query= : query string that we want to search for

These are the steps carried by our browser and google server to establish connections and provide results to us

1. DNS resolution:

When we type google.com browser automatically adds https and www to the URL and prepares to send the request, but before sending request browser need to know the IP address of the server that it will be communicating with, because it cannot communicate directly with host name i.e. google.com

We can take understand better with this example that when we need to call someone from our phone we search for that person's name because names are easy to remember as compared to mobile numbers, same with web URLs , its easier to remember the website name as compared to IP addresses.

e.g. lets take an IPv4 172.23.45.76 and IPv6 2001:0000:3238:DFE1:0063:0000:0000:FEFB

As we can see its difficult to remember even one IP and we have to remember hundreds of IP to access websites we daily visit.

So browser makes a DNS request to DNS server and asks for the IP of the given hostname (website name) and gets the IP.

2. Establishing secure link

Image Source: howtogeek.com

When we visit any website we see this padlock sign in address bar with label secure, so what is this label securing ?

This label shows that our connection to the server is secured and no one in the middle can intercept this connection and listen to it, but how does it really happen?

This happens after the process call SSL negotiation in which our browser verifies the server SSL certificate to check that the server is really that it claims to be. e.g. google.com will have a SSL certificate that is issued to google.com and unique to google.com so no one can pretend to be google.com

And after this negotiation a session key is created by our browser and google.com server and all the forgoing traffic is encrypted using this key.

3. Browser sends HTTP request

After all this procedure our browser send the HTTP request to the server requesting the specific resource from server.

Image Source: ntu.edu.sg

In HTTP request browser supplies with all the appropriate headers that are helpful to server to serve this request better.

4. Server sends final HTTP response including the web page we requested for

Image Source:  ntu.edu.sg

When server sends HTTP response to browser it also sends HTML content with it in most of the cases and our browser displays the HTML content to use, along with other contents including javascript and css.

So these are just the brief steps that are followed when we visit any website from our browser and there are many things we can go deep inside to learn more because no knowledge is enough.

Happy Hacking!!