Amazon Route 53: Nested Routing Policies.

Girish V P
ADIBI Technologies, Basavanagudi, Blore.
3 min readFeb 19, 2019

Amazon Route 53 supports many enhanced features which are not present in a normal DNS server. One of them is Nesting of Routing Policies. Though available default routing policies are enough for most of the cases, Nesting the policies can help you to avoid complex routing configurations in the DNS. Consider situation where you require weighted load balancing within recovery site located in a another AWS Region. Same way, when the primary site recovers, you want weighted load balance back in the primary site also. Let us see how this can accomplished with Amazon Route 53.

Configuration Setup

AWS Region Used: Mumbai, N Virginia
Domain names used : www.example.com
Primary Site: ind.example.com
Secondary Site: us.example.com
Number of web servers in primary Site: 2
Number of web servers in secondary Site: 2
Total Elastic IP addresses: 4
Routing Policies used: Weighed and Failover
Total number of health checks for web servers : 4x1
Total number of health check for Failover: 1
DNS Query
  1. Access AWS EC2 console for primary site(Mumbai Region). Launch two EC2 instance and configure web server. Repeat this for the Secondary Site (N Virginia) with another two instances. Recommended to use Elastic IPs.
  2. Access the Route 53 Console and create health check for each EC2 instance’s IP address endpoint. So you will be configuring total of four health checks at this time. Verify all checks returns status healthy,
  3. First you will adding the Weighted Routing policy for Mumbai Region(Primary site). Add A record for ind.example.com to weight 3 with one of the EC2 instance’s IP address in Mumbai Region. Repeat this with other EC2 instance’s IP address in the same AWS Region to different weight( I have used 1). Attach the respective health check to the record.
  4. Then you will be repeating the above steps for N Virginia Region(Secondary site)also. Add A record for us.example.com to weight 3 with one of the EC2 instance’s IP address in N Virginia Region. Repeat this with other EC2 instance’s IP address in the same Region to different weight( I have used 1). Attach the respective health check to the record.
  5. By this time you would have configured four A records.
  6. Now it is the time to configure Failover setup. Create a health check for domain endpoint www.example.com.
  7. Next create A record for www.example.com. with ALIAS option. Select Alias Target as ind.example.com. Select Routing Policy as Failover. Failover Record Type is Primary. Set Evaluate Target Health Yes. Associate with Health Check you created in the previous step.
  8. Then create another A record of www.example.com, for the secondary site this time. Select Alias Target as us.example.com. Select Routing Policy as Failover. Failover Record Type is Seconday. Set Evaluate Target Health Yes.
  9. Your configuration is complete and it is time to test.

Testing

Testing involves multiple steps,

  1. If you have Linux client execute host www.example.com, it has to return the IP address.
  2. Execute host www.example.com, it returns one of the IP addresses in the Primary site(Mumbai Region). When same command is repeated a few times, it has to return IP address of the second instance in the same Region based on the Weight you set.
  3. Stop One of the instances of the Primary site and repeat the same host command. Wait for a few minutes, you can see Route 53 resolve to second IP Address only.
  4. Now stop second Instance also which means primary site is fully down. Wait for a few minutes. Now you can see Route 53 returns IP address from the secondary site, in the proportion of weight within us.example.com.
  5. Now start all the stopped EC2 instances of primary sites. You can see that IP address resolved is of Primary Site.

Note: Between the each stage of testing wait for a few minutes ( 3 to 4) to get the desired result. Testing can also be done by accessing the websites configured. If you are using Windows client, you can use nslookup instead of host command.

Disclaimer: These experiments are done in a testing environment. Suggest you to setup experiment yourself and check thoroughly before implement in the production environment

Related Readings

--

--