Domain name server
- http
A request is made from the browser for a certain domain (ie. www.google.com). To be able to handle the request we need to find out which server we need to communicate with. In other words what is the Internet Protocol Address (IP) of the server that will be able to process the request made in the browser (we need to map domain name to the corresponding IP).
So let's go through the different steps that are made to retrieve the IP:
- check the caches on our computer;
- check the cache of the Domain Name Server;
- request the IP information from Root Server / external Name Servers;
- sent IP back to operating system;
- sent request to server with the retrieved IP.
Check internal (operation system)
Caching happens on multiple levels when you make a request to a domain. So before a Domain Name System (DNS) lookup is performed it will try to find the IP on your local machine first (in order: browser cache, DNS cache OS, check if there is a record in the hosts file configured for the requested domain). When no IP-address is found on the local machine it will go to the DNS resolver.
Check external (DNS)
Since a browser cannot perform a DNS lookup in the DNS Index to retrieve the IP, a DNS is used. The DNS will try to find a DNS record “domain.name=IP address” (IP that is associated with the domain name) and return it to the operation system.
Most of the time the resolver will be the DNS Resolver of the Internet Server Provider (ISP), but it can also be something like cloudflare DNS resolver or Google DNS. First it will check the cache of the resolver (ie. in case somebody else requested the same domain prior it might still be cached). If not cached the resolver will do the DNS lookup (query the Root Server) and return the IP.
Root Server
The external query is done through some steps, reading the domain name from "back to front". So a search for www.mysite.com will be searched as .com.mysite.www where the first "dot" represents the root.
- Query root DNS server (has TLD information)
- Query TLD server (has DNS Name information)
- Query Authoritative name server (has Domain information); returns the IP-address to the DNS resolver. The authoritative name server is the server where the actual DNS records are located (DNS zone file). Sometimes the first authoritative server routes the resolver to another authoritative server for a subdomain (ie. CNAME redirect)
Resolved IP
The resolved IP is returned through the different layers back to the operating system and added to the different caching levels on it's way back for subsequent requests.
Communication webserver
The browser sends the request to the server with the resolved IP. The request is send to the global network (aka intenet) and goes through different routers until it reaches the server with the IP-address and establishes a connection.
The server will handle the request (ie. send files to the browser needed to render a webpage).