Is there a way to localize dns entries? Meaning, that users from asia resolve mydomain.com to another ip than users from usa or europe. This would be helpful to give the users the server nearby. DNS is the only technique used so far, meaning I cannot place some softwarerouting or central system replacing the dns to solve this.
3 Answers
Yes, there are currently two popular solutions to this problem.
The first is called Anycast
, where the same IP block is literally in use in multiple locations around the world. That is to say, the name servers for your domain always return the same IP address, but that IP address is actually assigned to more than one set of physical servers.
You can read more about it here http://en.wikipedia.org/wiki/Anycast
The second technique again involves AnyCast, however this time, the IP address range being anycasted referes to our name servers themselves. As the nameservers will only requests from clients who they are closest too (as determined by the magic of BGP), they can themselves return IP addresses that are logically local to the client.
An example of this is google's l.google.com domain
From a host in Australia
crimson:~ dave$ host www.google.com
www.google.com is an alias for www.l.google.com.
www.l.google.com is an alias for www-notmumbai.l.google.com.
www-notmumbai.l.google.com has address 66.249.89.99
www-notmumbai.l.google.com has address 66.249.89.147
www-notmumbai.l.google.com has address 66.249.89.103
www-notmumbai.l.google.com has address 66.249.89.104
From a host in the US
[dave@odessa ~]$ host www.google.com
www.google.com is an alias for www.l.google.com.
www.l.google.com has address 74.125.95.99
www.l.google.com has address 74.125.95.147
www.l.google.com has address 74.125.95.104
www.l.google.com has address 74.125.95.106
www.l.google.com has address 74.125.95.105
www.l.google.com has address 74.125.95.103
So, the CNAME for www.google.com
resolves to www.l.google.com
, but when you resolve that, depending on your location, your client receives a different set of IP addresses. This is because the name server that received the request for www.l.google.com
was the local nameserver, relative to the client.
![](../../users/profiles/301.webp)
- 18,307
- 7
- 48
- 56
-
7This answer technically addresses the question, but I think it is rather useless in terms of being a real answer for an actual problem: most parties don't have anycast, so your answer is out of reach for all such parties. – cnst Mar 21 '13 at 01:27
-
so which registrant offer this solution? – dynamic Nov 07 '13 at 00:21
-
Also worth noting that DNS has this feature natively. Put a DNS server in a region with a record pointing to a webserver in that region. Repeat in other regions. Profit. – dmourati Jan 22 '15 at 08:16
-
@dmourati: wouldn't this propagate and update other DNS servers? I always assumed that DNS servers always propagate information until all of them are in sync. – Guru Prasad Feb 18 '16 at 13:54
-
@GuruPrasad Multiple hosts (usually in different geographic areas) are given the same unicast IP address and different routes to the address are announced through BGP. Routers consider these to be alternative routes to the same destination, though they are actually routes to different destinations with the same address. As usual, routers select a route by whatever distance metric is in use (the least cost, least congested, shortest). Selecting a route in this setup amounts to selecting a destination. == wikipedia / anycast ---- but it works better in IPv6 than this description – That Realtor Programmer Guy Aug 08 '17 at 07:45
I had same problem. Our company has customers in Russia and China and they all need very fast connection to our service. We used Amazon Route 53 Geo dns and just created two records, one will route customers from China to our Tokyo region cluster and customers from Russia to London.
![](../../users/profiles/425907.webp)
- 31
- 3
If you only want to localise servers for Asia, North America and Europe, then you could decide to run both your webapp and your DNS yourself.
With DNS, you could use something like the Split-Horizon DNS approach, which could either be achieved through integrated functionality of your DNS server (they may call it GeoDNS), or through a firewall that would redirect different IP-address ranges to different running instances of your DNS server (you could run several different copies of the server on your local machine, which will listen at different local IP-addresses).
You could probably get expected results in ≈90% of cases by replying to DNS requests from RIPE and AfriNIC IP-addresses with an A
record of your host in Europe, requests from APNIC — host in Asia, and requests from the IP-addresses from the /8 blocks administered by ARIN, LACNIC and the rest of the /8 address space with an A
record of your server in North America. This will have some wrong results in certain situations (some /8 blocks are shared between Europe and North America, some address space is anycast etc), but the worst that would happen is some extra latency to the affected party, so, it shouldn't be a big deal.
(And, yes, there should be a way to make these things easier, but, so far, it seems like there is none.)
![](../../users/profiles/110020.webp)
- 12,948
- 7
- 51
- 75