How does a browser finds the IP from a URL?

How does a browser finds the IP from a URL?

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


  1. IPv4 (something like 19.117.63.126)
  2. IPv6 (something like 684D:1111:222:3333:4444:5555:6:77)

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.

No alt text provided for this image


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.

No alt text provided for this image

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:

  1. Recursive query?— In a recursive query, a DNS client requires that a DNS server (typically a DNS recursive resolver) will respond to the client with either the requested resource record or an error message if the resolver can’t find the record.
  2. Iterative query?— in this situation the DNS client will allow a DNS server to return the best answer it can. If the queried DNS server does not have a match for the query name, it will return a referral to a DNS server authoritative for a lower level of the domain namespace. The DNS client will then make a query to the referral address. This process continues with additional DNS servers down the query chain until either an error or timeout occurs.
  3. Non-recursive query?— typically this will occur when a DNS resolver client queries a DNS server for a record that it has access to either because it’s authoritative for the record or the record exists inside of its cache. Typically, a DNS server will cache DNS records to prevent additional bandwidth consumption and load on upstream servers.


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:

  1. If the resolver does not have the?A records, but does have the?NS records?for the authoritative nameservers, it will query those name servers directly, bypassing several steps in the DNS query. This shortcut prevents lookups from the root and .com nameservers (in our search for example.com) and helps the resolution of the DNS query occur more quickly.
  2. If the resolver does not have the NS records, it will send a query to the TLD servers (.com in our case), skipping the root server.
  3. In the unlikely event that the resolver does not have records pointing to the TLD servers, it will then query the root servers. This event typically occurs after a DNS cache has been purged.

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.

要查看或添加评论,请登录

社区洞察

其他会员也浏览了