If I have multiple A records for the same DNS name (i.e. example1.com has two A records of 200.1.1.1 and 222.1.1.1) and for example one server is located in Canada and the other is located in Hong Kong, will the visitor's ip address and physical location automatically be used to direct them to the closest physical ip address? If one server goes down, will requests automatically be rerouted to the other server? If this is not the case, what are some good solutions to make this happen? I'm hoping that the "Internet" and all of it's routers and DNS servers are smart enough to at least go to the closest ip address...
3 Answers
Bind supports GeoIP. The key term your looking for is match-clients
match-clients { country_AR; country_CL; country_BR; };
![](../../users/profiles/44034.webp)
- 347
- 1
- 8
-
I've never used this, but I take it that all I would need is a linux server? Then I just point my domain hosts nameserver entries to this linux server once it's set up the way I want? – jjxtra Oct 28 '10 at 22:13
-
To be clear, this only solves the geo-location problem. If a user has been given the IP address of the Hong Kong server and it goes down, they will continue to use that IP address until it expires from their DNS cache. (Which may be hours.) Even then, BIND (as far as I know) has no concept of health checking, so when the user queries again, they will be return the IP address of the (still down) closest server. – Murali Suriar Oct 29 '10 at 09:30
-
BGP is the true load balancer. – Ash Palmer Oct 29 '10 at 10:07
The case you describe is called "round-robin DNS". Client PCs will pick a random IP address from the pool that are returned to it. It is not smart like you hoped.
The kind of service you're looking for is a DNS server that does a GeoIP lookup of the incoming request and serves an IP address closest to the requesters location. There are 3rd party DNS providers that support this, I believe.
![](../../users/profiles/3038.webp)
- 131,083
- 18
- 173
- 296
-
Do you have any experience with 3rd parties in this case? Or have you mostly managed this type of thing in house? – jjxtra Oct 27 '10 at 21:35
-
@John We're not doing anything of this sort. However, @Ash Palmer below describes how to set it up with ISC Bind. – sysadmin1138 Oct 27 '10 at 22:22
-
The problems you are trying to solve are separate, but related. Specifically, you are attempting to achieve the following two things:
- Load-balancing
- High availability
Load-balancing is distributing user requests across different servers. The way that users are distributed across servers can vary. To give but two examples:
- round-robin - alternate between your two servers for every request
- least-connections - have your load-balancing device keep track of how many connections each server is handling, and send new requests to the least loaded server
In this case, you want users to be directed to the server 'closest' to where the request is coming from. As mentioned in other answers, various DNS providers offer this service, as do DNS servers such as BIND.
High availability refers to ensuring that if one of your servers is no longer available that users are directed to an alternative. A common way of doing this is through the use of IP anycast; however, in order for this to work, your hosting provider must be willing to accept routing advertisement from you, among other things. See this question for a more in-depth discussion of anycast.
![](../../users/profiles/388.webp)
- 10,166
- 8
- 40
- 62
-
+1 for understanding the difference between the two. DNS (on its own) is the solution to neither. – Alnitak Oct 28 '10 at 07:11