Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do browsers handle a multiple IP response for a single hostname from DNS?

I want to know how this is handles or if there is a standard?

like image 726
Ankur Chauhan Avatar asked Oct 05 '10 19:10

Ankur Chauhan


People also ask

How does DNS work with multiple IP addresses?

A DNS server with round-robin enabled will have multiple different A records, each with the same domain name but a different IP address. Each time the DNS server is queried, it sends the IP address to which it most recently responded with to the back of the queue, operating on a loop.

Can a single hostname have multiple IP addresses?

So for hostname to IP address mapping, you only get one IP address per hostname (but multiple hostnames could resolve to the same IP address, which is the opposite).

Can a hostname have multiple IP addresses in DNS?

No, every host name can have multiple DNS A records pointing to different IPs. This is often used for high-level load balancing.

Can a domain name resolve to multiple IP addresses?

You can do it. That is what big guys do as well. As you see, the list of IPs rotated around, but the relative order between two IPs stayed the same. Update: I see several comments bragging about how DNS round-robin is not convenient for fail-over, so here is the summary: DNS is not for fail-over.


1 Answers

Browsers cache DNS Responses for a few minutes and typically attempt a connection with the first IP address returned in the DNS response. The same IP is used until the cache expires.

Internet Explorer caches DNS lookups for 30 minutes by default, as specified by the DnsCacheTimeout registry setting. Firefox caches DNS lookups for 1 minute, controlled by the network.dnsCacheExpiration configuration setting.

From: Yahoo Dev Network: Best Practices for Speeding Up Your Web Site

Therefore for multiple IP addresses to be used for load-balancing purposes, the DNS server must change the order of the addresses supplied in the response, choosing the order randomly or in a sequential "round robin" fashion. In fact, this is usually the default behaviour of DNS servers when they respond to hostnames with multiple A records.

There is no standard procedure for deciding which address will be used by the requesting application - a few resolvers attempt to re-order the list to give priority to numerically "closer" networks. Some desktop clients do try alternate addresses after a connection timeout of 30-45 seconds.

From: Wikipedia: Round robin DNS

like image 98
Daniel Vassallo Avatar answered Oct 11 '22 15:10

Daniel Vassallo