Friday 29 November 2013

What happens when you type a URL in your browser?

Most of the web browsers caches DNS information that they don't have to submit a DNS query each time it connects to a recently visited website. Your local DNS servers does the same, act as cache as well as recursive name servers. I presume your web browser as well as local DNS server doesn't cache any information about the website you typed.

1. You type www.mylinuxthoughts.com into your web browser's address bar and hit enter.

2. Your browser sends a request to the first DNS server listed in your DNS client configuration file /etc/resolv.conf.

3. This name server sends a query to a root name server, which returns a list of the authoritative name servers for the appropriate Top Level Domains (TLD's) (.com, .net, .org etc.)

4. The TLD DNS name servers look at the next part of the query from right to left of www.mylinuxthoughts.com, then direct the query to the authoritative name server for mylinuxthoughts.com.

5. Since you are looking for the IP address of www.mylinuxthoughts.com, your local DNS server queries the authoritative name server for A Resource Record of www.mylinuxthoughts.com and retrieves that to your localhost.

6. Now your browser will use this IP address to establish a communication with the web server which hosts the domain www.mylinuxthoughts.com that you want to visit. 

7. The TCP/IP stack of your system initiates a TCP 3-way handshake with the IP address of the server, typically on port 80/TCP, browser sends the HTTP request through TCP connection, once the handshake is successful.

8. The browser receives the HTTP response (status line), which has three parts separated by spaces. First HTTP version, second a response status code that gives the result of the request, and third an explanation of the status code. 

eg: HTTP/1.1 200 OK

9. Now your browser has a connection with www.mylinuxthoughts.com’s web server. The browser will send a HTTP/GET request to retrieve the html code of the specific page that is requested.

10. Once your browser receives the HTML code from the web server, it renders the HTML code to your browser window.

11. Now your local DNS server stores this IP in it's cache for future use.

12. When you close your browser, TCP connection terminates.


Ref: DNS and BIND, 5th Edition
        Pro DNS and BIND     
        Computer Networks, 4th Edition

No comments:

Post a Comment