How does a browser finds the IP from a URL?
Sagar Sharma
SSWE @ Accacia | Currently Working on NestJS | PostgreSQL | AWS | Neo4j | K8S
Have you ever wondered what happens when type a url in your browser and hit enter then it loads the website . How does your computer know where to send the request and how it figures it out.
What is DNS?
The Domain Name System (DNS) is like a phonebook of the Internet. Humans access information online through?domain names, like google.com or youtube.com. But computers can only talk to each other with their IP addresses. IP address have 2 forms
Each device connected to the Internet has a unique IP address which other machines use to find the device. This IP address depends on which network you are on. For example. If you are in your home/office network it is a local network which is already behind your isp network so your ip will be only accessible to your network unless you opt for a public ip address where your ISP will give you a public IP which can be accessed from anywhere in the world directly.
How does DNS work?
The process of DNS resolution involves converting a hostname (such as?www.example.com)?into a computer-friendly IP address (such as 192.168.1.1). An IP address is given to each device on the Internet, and that address is necessary to find the appropriate Internet device — like a street address is used to find a particular home. When a user wants to load a webpage, the hostname should be converted to IP address.
In order to understand the process behind the DNS resolution, it’s important to learn about the different components a DNS query is passed between. As a user you don’t have to do anything browsers automatically do everything for you. You just wait and relax for your website to load.
What is a DNS resolver?
The DNS resolver is the first stop in the DNS lookup, and it is responsible for dealing with the client that made the initial request. The resolver starts the sequence of queries that ultimately leads to a URL being translated into the necessary IP address.
Note: A typical uncached DNS lookup will involve both recursive and iterative queries.
It’s important to differentiate between a?recursive DNS?query and a recursive DNS resolver. The query refers to the request made to a DNS resolver requiring the resolution of the query. A DNS recursive resolver is the computer that accepts a recursive query and processes the response by making the necessary requests.
What are the types of DNS queries?
In a typical DNS lookup three types of queries occur. By using a combination of these queries, an optimized process for DNS resolution can result in a reduction of distance traveled. In an ideal situation cached record data will be available, allowing a DNS name server to return a non-recursive query.
领英推荐
3 types of DNS queries:
What is DNS caching? Where does DNS caching occur?
The purpose of caching is to temporarily stored data in a location that results in improvements in performance and reliability for data requests. DNS caching involves storing data closer to the requesting client so that the DNS query can be resolved earlier and additional queries further down the DNS lookup chain can be avoided, thereby improving load times and reducing bandwidth/CPU consumption. DNS data can be cached in a variety of locations, each of which will store DNS records for a set amount of time determined by a?time-to-live (TTL).
Browser DNS caching
Modern web browsers are designed by default to cache DNS records for a set amount of time. The purpose here is obvious; the closer the DNS caching occurs to the web browser, the fewer processing steps must be taken in order to check the cache and make the correct requests to an IP address. When a request is made for a DNS record, the browser cache is the first location checked for the requested record.
In Chrome, you can see the status of your DNS cache by going to chrome://net-internals/#dns.
Operating system (OS) level DNS caching
The operating system level DNS resolver is the second and last local stop before a DNS query leaves your machine. The process inside your operating system that is designed to handle this query is commonly called a “stub resolver” or DNS client. When a stub resolver gets a request from an application, it first checks its own cache to see if it has the record. If it does not, it then sends a DNS query (with a recursive flag set), outside the local network to a DNS recursive resolver inside the Internet service provider (ISP).
When the recursive resolver inside the ISP receives a DNS query, like all previous steps, it will also check to see if the requested host-to-IP-address translation is already stored inside its local persistence layer.
The recursive resolver also has additional functionality depending on the types of records it has in its cache:
So thats how basically a simple search works on the internet. Isn’t it amazing to know that what helps us to use the internet so seamlessly and without knowing and worrying about such small details in the bigger picture.