Amazon Route 53
Route 53 is Amazon's DNS service. It allows you to map your domain names to EC2 instances, load balancers, and S3 buckets. Route 53 is a global service.
TODO: note that Route 53 supports MX records.
The Domain Name System (DNS) is used to convert human friendly domain names (such as http://penson.io) into an Internet Protocol (IP) address (such as http://220.127.116.11). IP addresses are used by computers to identify each other on the network.
IP addresses commonly come in 2 different forms, IPv4 and IPv6. The IPv4 space is a 32 bit field and has over 4 billion different addresses. IPv6 was created to solve the depletion issue and has an address space of 128 bits which in theory is 340 undecillion addresses.
The DNS port is port 53. That's how Route 53 got its name!
Top Level Domains
Domains names consist of a string of characters separated by periods (e.g. google.com, bbc.co.uk). The last word in a domain name represents the top level domain (TLD). The second word in a domain name is known as a second level domain (SLD) (e.g. the co in bbc.co.uk, or the penson in penson.io).
Top level domain names are controlled by the Internet Assigned Numbers Authority (IANA) in a root zone database. Root servers sit at the top of the DNS hierarchy.
A domain registrar is an authority that can assign domain names directly under one or more top-level domains. These domains are registered with InterNIC, a service of ICANN, which enforces uniqueness of domain names across the Internet. Each domain name becomes registered in central database known as the WhoIS database.
A DNS database consists of resource records (RRs). There are various types of RRs in DNS.
Start of Authority (SOA) Records
- The name of the server that supplied the data for the zone.
- The administrator of the zone.
- The current version of the data file.
- The number of seconds a secondary name server should wait before checking for updates.
- The number of seconds a secondary name server should wait before retrying a failed zone transfer.
- The maximum number of seconds that a secondary name server can use data before it must either be refreshed or expire.
- The default number of seconds for the time-to-live file on resource records.
Name Server (NS) Records
Name Server (NS) records are used by Top Level Domain servers to direct traffic to the Content DNS server which contains the authoritative DNS records.
The length of time that a DNS record is cached on either the Resolving Server or the user's own local PC is equal to the value of the Time To Live (TTL) in seconds. The lower the time to live, the faster changes to DNS records take to propagate throughout the Internet.
A Canonical Name (CNAME) can be used to resolve one domain name to another. For example, you may have a mobile website with the domain name http://m.penson.io that is used for when users browse to your domain name on their mobile devices. You may also want the name http://mobile.penson.io to resolve to this same address.
Alias records are used to map resource record sets in your hosted zone to Elastic Load Balancers, CloudFront distributions, or S3 buckets that are configured as websites. The are an Amazon-specific records.
Alias records work like a CNAME record in that you can map one DNS name
(www.example.com) to another target DNS name
(elb1234.elb.amazonaws.com). However, a CNAME can't be used for naked domain
names (zone apex, no
www). You can't have a CNAME for http://penson.io, it
must be either an A record or an Alias.
Alias resource record sets can save you time because Amazon Route 53 automatically recognizes changes in the record sets that the alias resource record set refers to. For example, suppose an alias resource record set for example.com points to an ELB at lb1-1234.us-east-1.elb.amazonaws.com. If the IP address of the load balancer changes, Amazon Route 53 will automatically reflect those changes in DNS answers for example.com without any changes th the hosted zone that contains resource record sets for example.
Elastic Load Balancers do not have pre-defined IPv4 addresses. You resolve to them using a DNS name. Create an alias for these names is the most common use for Alias Records.
Registering a Domain Name
Amazon Route 53 is a domain registrar. You can register a domain name through the AWS console.
With Route 53, there is a default limit of 50 domain names. However, this limit can be increased by contacting AWS support.
Create a routing policy with the AWS console. Navigate to Route 53, select Hosted Zones, then click a domain.
This is the default routing policy when you create a new record set. This is most commonly used when you have a single resource that performs a given function for your domain, for example, one web server that serves content for the http://penson.io website.
The user makes a DNS request to Route 53. Route 53 then forwards that request to the EC2 instances in a particular region.
Weighted Routing Policies let you split your traffic based on different weights assigned. For example, you can set 10% of your traffic to go to US-EAST-1 and 90% to go to EU-WEST-1. This can be useful for A/B testing.
The weight itself is a value from 0 to 255. This value is translated to a probability (weight / sum(weights)).
Latency-based routing allows you to route you traffic based on the lowest network latency for your end user (i.e. which region will given them the fastest response time).
To use latency-based routing you create a latency resource record set for the Amazon EC2 (or ELB) resource in each region that hosts your website. When Amazon Route 53 receives a query for your site, it selects the latency resource record set for the region that gives the user the lowest latency. Route 53 then responds with the value associated with that resource set.
Failover routing policies are used when you want to create an active/passive set up. For example you may want your primary site to be in EU-WEST-2 and your secondary disaster recovery (DR) site in AP-SOUTHEAST-2.
Route 53 will monitor the health of your primary site using a health check. Create a health check through the Route 53 page.
Geolocation routing lets you choose where your traffic will be sent based on the geographic location of your users (i.e. the location from which DNS queries originate). For example, you might want all queries from Europe to be routed to a fleet of EC2 instances that are specifically configured for your European customers. These servers may have the local language of your European customers and all prices are displayed in Euros.