• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Which IP to use from a list of available IPs resolved by DNS??

Cooky

Golden Member
Say a user is on host 170.210.17.145 and is using IE to connect to www.website.com. The host receives a list of multiple IPs from DNS server: {192.168.0.1, 128.0.0.1, 200.47.57.1, 170.21.10.130}.

Which IP would the host use to create the connection and why??
I know it can't be the 1st one because it's an internal IP but how about the rest of them??

I didn a research on google and all the sites I found only explain how DNS works in general and don't explain what's gonna happen if more than 1 IP gets returned from the DNS query.
Any feedback is highly appreciated.
 
When there is more than one IP address associated with a hostname, the DNS server will do a round-robin algorythm. Assume there's three IP's for a hostname. For each reqest, the DNS server will return back all three IP's, but in a different order - request #1 gets IP #1 first in the list, request #2 gets IP #2 first in the list, request #3 gets IP #3 first in the list, request #4 gets IP #1 first in the list , request #5 gets IP #2 first in the list, etc.

I assume that you're using NSLOOKUP or DIG to do a query. Those tools will list all IP's, but it's the order that matters. Your machine will use the first address in the list to do it's work. It will "stick" to that IP until it's time-to-live (see "ipconfig /displaydns" to list the contents of the DNS cache, "ipconfig /flushdns" to clear the cache).

One note - It is, in general, a very bad idea to include a non-routable IP for a public website. That means that 1/n (n being the total number of IP's) will not be able to contact the server from outside the network. I don't think that any OS is smart enough to look at all the IP addresses that respond and pick the closest route.

- G

 
Garion, thanks for the quick reply.

What would be the reason why the host would use 170.21.10.130, for it being the last IP in the list??
 
What would be the reason why the host would use 170.21.10.130, for it being the last IP in the list??

Bad timing? You can't guarantee which IP the host will use if there's multiple in the list, the order they're returned seems to be determined by the order on the DNS server but which one comes first isn't guaranteed. That and gethostbyname returns all of the addresses associated with a name so if the app was trying to be overly smart it could use whichever one it wants.

Below I looked up the addresses for google.com 4 times, look at the addresses returned:

$ host google.com
google.com A 216.239.57.99
google.com A 216.239.37.99
google.com A 216.239.39.99
$ host google.com
google.com A 216.239.37.99
google.com A 216.239.39.99
google.com A 216.239.57.99
$ host google.com
google.com A 216.239.39.99
google.com A 216.239.57.99
google.com A 216.239.37.99
$ host google.com
google.com A 216.239.39.99
google.com A 216.239.57.99
google.com A 216.239.37.99
 
As Garion pointed out the DNS server will "round robin" the addresses. The DNS server doesn't care what the IP addresses are.

His job is to provide answers to your question. Your question was "what are the address records for www.website.com". The DNS server answer is "address records for www.website.com are A, B, C, D"

where A, B, C, D are the IP addresses. When the same question is asked of the name server again he'll say "address records for www.websit.com are B, C, D, A"

get it? it rotates the list everytime it is asked. when using a browser it simple take the first address in the list.
 
Back
Top