Amazon AWS Route 53 GEO DNS Configurations
You can send visitors to different servers based on country of their IP address using Amazon Route 53 cloud based dns server. For example, if you have a server in Amsterdam, a server in America, and a server in Singapore, then you can easily route traffic for visitors in Europe to the Amsterdam server, people in Asia go to the Singapore server and those in the rest of the world be served by the American server. This will results into the various kinds of benefits such as:
- Better performance as you are sending web site visitors to their nearest web server.
- Reduced load on origin.
- Geomarketing/online advertising.
- Restricting content to those geolocated in specific countries (I am not a big fan of DRM).
- In some cases you can get potentially lower costs and more.
In this post, I will explain how to configure and test GeoDNS using AWS Route 53 service.
Our sample setup
Please note that IPs (1.1.1.1) or CNAMEs (w.usa.cyberciti.biz) can be hosted by AWS or your own server anywhere in the world.
AWS Route 53 routing policy
From the Route 53 documents:
If your application is hosted on Amazon EC2 instances in multiple EC2 regions, you can reduce latency for your end users by serving their requests from the EC2 region for which network latency is lowest. Route 53 latency-based routing lets you use DNS to route end-user requests to the EC2 region that will give your users the fastest response.
It is possible to use Route 53′s Latency Based Routing (LBR) feature with non-AWS endpoints or IP address. Route 53 don’t restrict what IPs or CNAMEs you can tag with a region. AWS dns server will route traffic to those IPs/CNAMEs “as if” those IPs or CNAMEs were hosted in whichever AWS region you choose to tag. The following is the current list of regions supported by Route 53 LBR:
- Nothern Virginia, US: us-east-1
- Nothern California, US: us-west-1
- Oregon, US: us-west-2
- Ireland, EU: eu-west-1
- Singapore, Asia: ap-southeast-1
- Tokyo, Asia: ap-northeast-1
- Sydney, Asia: ap-southeast-2
- Sao Paulo, South America: sa-east-1
Configuration
First, open the Amazon Route 53 console at https://console.aws.amazon.com/route53/ > Choose your existing domain > Click on the Go to Record Sets button > Click on the Create Record Set button.
CNAME geodns settings for USA Dallas server
- Set Name to www.l.
- Choose Type to CNAME.
- Set TTL to 30 seconds.
- Set Value to w.usa.cyberciti.biz. seconds.
- Set Routing Policy to Latency.
- Set Region to us-west-1.
- Set ID to Dallas, TX, Data Center.
- Click the Create Record set button to save the changes.
Set an IP address for CNAME w.usa.cyberciti.biz
Visit the Amazon Route 53 console at https://console.aws.amazon.com/route53/ > Choose your existing domain > Click on the Go to Record Sets button > Click on the Create Record Set button.
- Set Name to w.usa.
- Set Type to A - IPv4 address.
- Set TTL to 30 seconds.
- Set Value to 1.1.1.1. Please replace IP address 1.1.1.1 with your actual AWS endpoint or any other valid public IP address in US.
- Set Routing Policy to Simple.
- Click the Create Record set button to save the changes.
Repeat this process for the rest of your HTTP and SMTP services. At the end, your setup should look like as follows:
Test it
Use the following dig or host dns lookup command line utilities to verify new settings:% dig +short www.l.cyberciti.biz.
Sample outputs from various locations:
## Asia ##
w.sg.asia.cyberciti.biz.
3.3.3.3
## Office in UK ##
w.europe.cyberciti.biz.
2.2.2.2
## IDC in US ##
w.usa.cyberciti.biz.
1.1.1.1
The following images shows the accuracy of geo name-to-IP address resolutions around the world for www.l.cyberciti.biz:
Limitations
Use of proxy servers, third party DNS servers other than your ISPs and VPN may give a false geo location to end-users.
The dig command output from my home using Google free DNS servers:% dig +short www.l.cyberciti.biz. @8.8.8.8
Sample outputs:
w.sg.asia.cyberciti.biz.
3.3.3.3
However, OpenDNS sent visitor to EU data center% dig +short www.l.cyberciti.biz. @208.67.222.222
Sample outputs:
w.europe.cyberciti.biz.
2.2.2.2
Conclusion
The Route 53 provides a simple, and accurate geo targeting based on LBR. This is useful to direct traffic to a server geographically closer to the end-user. The server can be hosted with AWS or anywhere else in the world. The next logical step is to set up a database replication and upload your Python/PHP/Perl and other files (JS/CSS/Images) to servers so that end users can view the same content.
References
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
Amazon AWS Route 53 GEO DNS Configurations
Amazon AWS Route 53 GEO DNS Configurations