Reputation: 23276
This is program that shows the ip for requested website: {
import java.net.*;
class verify {
public static void main(String args[]) throws UnknownHostException{
InetAddress address=InetAddress.getLocalHost();
System.out.println(address);
address=InetAddress.getByName("www.bcetgsp.ac.in");
System.out.println(address);
InetAddress SW[]=InetAddress.getAllByName("www.nba.com");
for(int i=0;i<SW.length;i++)
System.out.println(SW[i]);
}
}
}
here i get 2 ip's for nba.com
What is the reason for this? what i have heard is"it is common for a single name to be used to represent several machines."But if we go by this and replace www.nba.com by www.google.com,i get only 1 ip.(why?)
Upvotes: 1
Views: 941
Reputation: 104080
Note that using Anycast, a host may only have a single IP address in DNS but may be handled by physically many machines spread out over the globe. So, even though the usual answer for providing fault tolerance and load balancing is through DNS round-robin or geo-location, using Anycast and smart BGP routing can provide similar fault tolerance, load balancing, and network-topology appropriate routes.
Of course, Anycast is best suited to stateless tasks, such as DNS lookups; it can be used to provide TCP services, but systems requiring stored per-client state on servers may not be optimum, as clients may connect to different servers as routing topology changes. Without Anycast, the routes might just be non-optimal to the endpoint, but still function. (A better route to a different host may exist: with Anycast, packets will be redirected. Without Anycast, packets will take the slower route to the already-established but less-good peer.)
Upvotes: 0
Reputation: 11220
Google records don't return only 1 ip:
$ host google.com
google.com has address 74.125.230.84
google.com has address 74.125.230.83
google.com has address 74.125.230.80
google.com has address 74.125.230.81
google.com has address 74.125.230.82
Upvotes: 0
Reputation: 26904
Short answer: a DNS record can be mapped to a number of IPs for redundancy (fault tolerance) reasons.
It means that lots of servers answer for nba.com. It's normal.
Well, I'm unsure... Google definitely doesn't have one single server to answer your queries (otherwise they won't be 24/7 online with highest availability), but I have a possible explanation.
I remember that www.google.com points to multiple CNAME records, each one resolving to 1 final IP address. Probably, www.nba.com is directly mapped to several IPs (2 in your case, too few for such an important website).
Upvotes: 2
Reputation: 9676
I guess that's because they have server farm over there. One name can be shared across many IPs, which are selected in a round robin fashion upon each DNS request.
Upvotes: 1