Web Networking: Behind The Scenes of Web Browsing
An exploration on Domain Name Systems (DNS)
Table of contents
I just got myself a brand new computer, which I am so in love with, and quickly proceeded to configure it. I installed many apps and also configured the WIFI. I needed to log into my Facebook App for recent messages and updates from my connections. My new PC's web browser has not connected to the internet before so it has not searched Facebook.com ever. Well, it may have but not under my ownership. Both my system and the Facebook web server are connected to the internet which is why I want my web browser to land me on the Facebook home page. It does not bother me how my browser fetches the web page. I just want to chill out on social media. That's all!
So I want to share with you what I learned and what happens behind the scenes when you surf the internet.
“ There is a connection that happens that I would not see or notice and here it is … “
Although I know the domain name to be Facebook, What I do not know is that the computer does not know domain names, the only address it can recognize is the IP address.
Every computer that connects to the internet has an IP and each time a user connects to the internet, the connecting device is assigned a public IP by the ISP(Internet Service Provider). IP addresses can be peculiar among devices that are coming out from the same endpoint which are connected to the same router. A router is a networking device or a gateway that enables two or multiple computers to internally share a network. This is why when multiple devices that are connected on the same endpoint connect to the internet, they are assigned the same IP address while each device retains its private IPs.
Domain Name System (DNS) is the unsung hero of the internet, translating IPs into domain names that humans can easily read, memorize, and use. When a user types Facebook.com on the browser, the browser talks to the DNS to produce the expected results. Either way. IANA & ICANN are organizations that are responsible for mapping out and assigning IPs to domains.
A DNS server is like a database that stores IP mappings of websites associated with their domain names. It is some sort of a high-end directory, recall those 20th-century mini books where we write down people’s names, phone contacts, and addresses. So basically, when I type facebook.com from my mobile phone or computer, behind the scenes, the browser, which does not know the IP mapped to facebook.com, checks my local DNS server and if it does not find it within my device, it would move to the authoritative DNS server hosted somewhere over the internet to fetch the IP for Facebook.com, registers it in my cache for quick retrieval when I want to browse Facebook subsequently.
The DNS is not sitting pretty under the ownership and control of one gigantic organization, it is a distributed effort of different organizations spinning across a wide spread of servers
THE DNS PROCESS
The DNS process tunes my search down until the browser reaches the DNS server that houses the domain I am looking for. The search process starts within the local DNS server located within the system and some hostnames are mapped to IP addresses. Since there is no known IP mapping for Facebook within my system. It is a new system. Remember! My browser moves over to the Root server to make the query - “Who is facebook.com?”. If the Root server can not identify any IP mapped to that domain, it would redirect the query to other servers that may provide the IP address to the website I am searching for. There are about 13 Root servers spread around the world to handle DNS queries like this. Root servers may not have the address my browser is looking for but they have information that could help find the address. And this makes it recursive.
In a similar pattern, the browser makes another query on the Top-Level Domain server which in this case is “.com”. The TLD searches within its zone record for the actual name server for facebook.com and even though it won't arrive at the actual address yet, it gives the IP address of servers that are associated with the Facebook domains and subdomains and tells the browser to look more within the Domain server to find the exact match. TLD servers here are recursive as well since they provided some results that were instrumental to the search.
The browser moves further to make another query on the DNS server, this server searches within its records for this host. It gives the exact IP address so that I can view the Facebook page that I wanted. The DNS server is authoritative since it holds the actual records my browser has been looking for.
All these processes happen within milliseconds. (The internet is a wonder!)
Now that the IP is found, what next?
My browser uses that IP it fetched from the DNS to establish a TCP connection to port 80 on the web server. This port produces a connection between my web browser and the web servers of the websites I visit. Through this connection, my browser will render the particular page I requested right in my browsing window. With that, I can move from one page to another and when I’m done with Facebook and have left the site, the connection will end but the information will not be erased from my system, to enable my browser to load facebook.com faster next time, my browsing details for facebook.com will be stored somewhere in my browser called Cache.