google.com has at least these ip:
18.104.22.168 22.214.171.124 126.96.36.199
ping just pick one of them randomly?
migrated from stackoverflow.com Sep 17 '11 at 9:06
This question came from our site for professional and enthusiast programmers.
The answer is it depends on how your DNS resolver is setup and also how the DNS server for the domain in question is set up.
The DNS resolver on your ping source host will consult the OS and network configuration to lookup the host you want to ping. If this is a new host, one for which you haven't previously done a lookup, the DNS query sequence will go from start to finish.
The number of A records and contents of those records as well as what order they are are returned depends on the name servers for the target ping destination domain. This process is a whole other discussion.
Your DNS client will pick one of those IPs returned in the A records and your ping will start sending IMCP echo-request messages to that destination IP.
Your local OS may cache one or more of the responses for some period of time, typically but not always the TTL specified in the A record. There is also another caching opportunity at your DNS resolver, again, which typically but not always will follow the TTL.
One final wrinkle is the so-called sort ordering done by some DNS clients. See:
It just picks one of them. It's not quite random -- for example, if one of them is on the same local network, it will typically pick that one.
THE PING PROCESS
The process above is repeated until all requested ICMP ECHO packets have been sent and their responses have been received or the default 2-second timeout expired. The default 2-second timout is local to the host initiating the PING and is NOT the Time-To-Live value in the datagram.