Overview and What You Will Learn
Amazon Route 53 is AWS's highly available authoritative DNS service. It answers DNS queries for your domains, monitors the health of your endpoints, and chooses which answer to return using a routing policy. In this lab you create a hosted zone, add records, attach a health check, and use weighted routing to split and fail over traffic.
By the end you will be able to:
- Explain how a DNS lookup moves from resolver to root, TLD and authoritative server
- Choose between public and private hosted zones
- Use A, AAAA, CNAME, NS and Alias records correctly, and know why Alias replaces CNAME for AWS resources
- Change records safely using a TTL strategy
- Pick the right one of the 8 routing policies for a given requirement
- Build endpoint, calculated and CloudWatch-based health checks
- Point a domain bought elsewhere (such as GoDaddy) at Route 53
- Connect on-premises DNS with Route 53 Resolver inbound and outbound endpoints
Why This Matters in Production
DNS is the first hop of every request, so a wrong record or a missing health check takes an application offline even when every server is healthy. A trading platform like Zerodha can use Failover routing so that when the primary Region fails its health check at market open, traffic moves to a standby Region with no human action. A food delivery company like Swiggy can use Latency-based routing to send users to the nearest healthy Region, and a streaming service like Hotstar can use Weighted routing to shift 10 percent of traffic to a new release and roll back by changing one number.
Route 53 also carries a 100 percent availability SLA for DNS queries answered by its authoritative name servers, so DNS itself is rarely the weak link. Your records and health checks are.
Core Principles
How Does DNS Resolution Work Step by Step?
A recursive resolver (your ISP or a public one such as 8.8.8.8) finds the answer for you by asking the root servers, then the TLD servers, then your domain's authoritative servers, and caching the result for the record's TTL. The full walk usually takes tens of milliseconds, and cached answers skip most of it.
| Term | Meaning |
|---|---|
| Authoritative server | Holds the definitive answer for a domain |
| TLD | Top-level domain such as .com or .in |
| FQDN | Fully qualified name such as api.example.com |
| Zone file | All records for a domain |
What Is a Hosted Zone in Route 53?
A hosted zone is the container for all DNS records of a domain and its subdomains. A public hosted zone answers queries from the internet. A private hosted zone answers only for the VPCs you associate with it, so microservices can use names such as db.company.internal instead of hardcoded private IPs. Each hosted zone costs about $0.50 per month, so check current pricing for your account.
- Public example: example.in resolves to an ALB for anyone on the internet
- Private example: db.company.internal resolves to 10.0.0.35 only inside the VPC
Which DNS Record Types Does Route 53 Support?
The records you use most are A (name to IPv4), AAAA (name to IPv6), CNAME (name to another name), and NS (which name servers are authoritative). A CNAME cannot be created at the zone apex (example.com itself), only on subdomains such as www.example.com. When you move a domain to Route 53, you copy its four NS records to your registrar so the internet knows Route 53 is authoritative.
What Is the Difference Between CNAME and Alias Records?
An Alias record is a Route 53 extension that points a name at an AWS resource. Unlike a CNAME, it works at the zone apex, costs nothing for queries to AWS targets, follows IP changes automatically, and has no TTL of your own. AWS resources such as load balancers expose a DNS hostname, not a fixed IP, so Alias is the right choice.
| CNAME | Alias | |
|---|---|---|
| Root domain | Not allowed | Allowed |
| Query cost | Charged | Free to AWS targets |
| TTL | You set it | Managed by Route 53 |
Valid Alias targets include Elastic Load Balancers, CloudFront, API Gateway, Elastic Beanstalk, S3 website endpoints, VPC interface endpoints, Global Accelerator, and another record in the same hosted zone. An EC2 instance DNS name is not a valid target.
Common MistakeCreating a CNAME for example.com. DNS does not allow it at the zone apex and Route 53 rejects it. Use an Alias record instead.
How Should You Set TTL When Changing a DNS Record?
TTL is how long resolvers cache an answer. A high TTL lowers query cost but leaves clients on the old value after a change, and a low TTL propagates changes quickly but increases queries. To change a record safely, lower the TTL first and wait for the old TTL to expire before you edit.
- Step 1: Lower the TTL to 60 seconds
- Step 2: Wait at least as long as the old TTL (for example 24 hours for a 86400 TTL)
- Step 3: Make the change
- Step 4: Wait 60 seconds, then raise the TTL again
TipIf you skip step 2, some resolvers still hold the old high TTL and ignore your change for hours.
How Do Route 53 Health Checks Work?
A health check probes an endpoint from checkers in about 15 locations around the world and marks it healthy when enough of them succeed. Route 53 health checkers sit outside your VPC, so they can test public endpoints directly but not private ones.
- Endpoint checks use HTTP, HTTPS or TCP, with a 30 second interval by default or 10 seconds for a higher cost
- The endpoint is healthy when about 18 percent or more of checkers report it healthy, and HTTP checks pass on a 2xx or 3xx response
- String matching can look for text in the first 5,120 bytes of the response
- Calculated health checks combine child checks with AND, OR or NOT, which is useful for maintenance on one resource
- For private resources, a CloudWatch alarm watches a metric and the health check follows the alarm state
RememberHealth checkers connect from public AWS IP ranges, so your security group or firewall must allow them or a healthy server will look down.
What Are the 8 Route 53 Routing Policies?
Route 53 has eight routing policies, and each answers one question: how should Route 53 pick the record to return? Use the table to choose, then read the detail for the policies you need.
| Policy | Use it to |
|---|---|
| Simple | Return one or more values with no health checks |
| Weighted | Split traffic by percentage |
| Latency | Send users to the lowest-latency Region |
| Failover | Run active-passive disaster recovery |
| Geolocation | Route by the user's physical location |
| Geoproximity | Shift traffic with a bias toward a Region |
| IP-based | Route by client CIDR range |
| Multivalue | Return up to 8 healthy records |
- Simple: One record may hold several values, and the client picks one at random. It cannot use health checks.
- Weighted: Traffic share is the record's weight divided by the sum of weights, so 70, 20 and 10 give 70, 20 and 10 percent. A weight of 0 stops traffic to that record, and if all weights are 0 every record is returned equally. Supports health checks. Use it for canary releases and blue-green shifts.
- Latency: Routes by measured network latency between users and AWS Regions, not by distance. A user in Germany may reach us-east-1 if it is faster than eu-west-1. Supports health checks.
- Failover: The primary record must have a health check. When it fails, Route 53 returns the secondary record. Without the health check, no failover ever happens.
- Geolocation: Routes by continent, country or US state, and the most specific match wins. Always add a Default record or unmatched users get no answer.
- Geoproximity: Considers the location of users and resources, and a bias from -99 to +99 expands or shrinks each resource's catchment area. Use it to move traffic gradually from one Region to another.
- IP-based: You supply CIDR ranges mapped to endpoints, for example to send a known ISP's range to the closest endpoint.
- Multivalue: Returns up to 8 records and only the healthy ones, and the client chooses. It improves availability but is not a replacement for a load balancer.
RememberGeolocation routes by where the user is, and Latency routes by which Region responds fastest. A user next to a Region can still have higher latency to it.
How Do You Use a Domain From GoDaddy With Route 53?
Registrar and DNS host are separate roles, so you can buy a domain anywhere and let Route 53 answer its DNS queries. Create a public hosted zone, copy the four NS records Route 53 gives you, and paste them into the registrar's nameserver settings. From then on you manage all records in Route 53.
How Does Hybrid DNS Work With Route 53 Resolver Endpoints?
Resolver endpoints connect Route 53 with your on-premises DNS over VPN or Direct Connect. An inbound endpoint lets on-premises servers resolve names in your private hosted zones, and an outbound endpoint plus forwarding rules lets VPC resources resolve on-premises names.
Detailed Step-by-Step Practical Lab
This lab builds a weighted pair of records with a health check. You need a domain you own, such as devops-lab.in, and two EC2 web servers with public IPs.
Step 1: Create a public hosted zone
aws route53 create-hosted-zone \ --name devops-lab.in \ --caller-reference "lab-$(date +%s)"Note the four NS values in the output and set them as the nameservers at your registrar.
Step 2: Create a simple A record in the console
In Route 53, open Hosted zones, select devops-lab.in, then Create record.
- Record name: www
- Record type: A
- Value: the public IP of server 1, for example 13.235.45.67
- TTL: 60 (low for testing, use 300 or more in production)
Test it with a resolver query:
dig www.devops-lab.in @8.8.8.8Step 3: Create a health check
In Route 53, open Health checks, then Create health check.
- Name: server-1-health
- What to monitor: Endpoint, by IP address
- Protocol HTTP, IP 13.235.45.67, port 80, path /
- Request interval 30 seconds, failure threshold 3
After about two minutes the status should show Healthy. If it does not, check that the security group allows port 80 from the internet.
Step 4: Create weighted records
Create two A records with the same name, api, in the hosted zone.
- Record 1: value server 1 IP, routing policy Weighted, weight 70, record ID server-1, health check server-1-health
- Record 2: value server 2 IP, routing policy Weighted, weight 30, record ID server-2
Step 5: Observe the traffic split
for i in 1 2 3 4 5 6 7 8 9 10; do dig +short api.devops-lab.in @8.8.8.8; doneRoughly 7 of 10 answers should be server 1. Resolver caching can make small samples uneven.
Step 6: Test failover behaviour
Stop the web service on server 1 and wait about 90 seconds (3 checks at 30 seconds). The health check changes to Unhealthy and Route 53 stops returning server 1.
aws route53 get-health-check-status --health-check-id <HEALTH-CHECK-ID>for i in 1 2 3 4 5; do dig +short api.devops-lab.in @8.8.8.8; doneEvery answer should now be server 2.
Step 7: Clean up
Delete the api and www records, delete the health check, then delete the hosted zone. NS and SOA records are removed with the zone. Remember to stop the EC2 instances.
Production Best Practices & Common Pitfalls
- Use Alias records for AWS resources: They are free, work at the apex and follow IP changes.
- Lower TTL before a planned change: Then wait out the old TTL.
- Always attach health checks to Failover and Weighted records: Without them Route 53 keeps returning a dead endpoint.
- Add a Default record for Geolocation: Otherwise unmatched locations get no answer.
- Combine Latency routing with health checks: Users go to the fastest Region, and unhealthy Regions are skipped automatically.
- Let health checkers through: Allow Route 53 checker IP ranges in security groups and firewalls.
- Do not confuse Geolocation and Latency: One is about where users are, the other about response time.
- Use private hosted zones for internal names: Associate every VPC that needs to resolve them.
Common MistakeUsing Failover routing without a health check on the primary record. Route 53 cannot know the primary is down, so it never fails over.
TipFor a multi-Region production setup, use Latency records with a health check on each one. If a Region fails during a traffic peak, Route 53 sends users to the next fastest healthy Region without paging anyone.
Quick Reference & Troubleshooting Commands
| Task | Command |
|---|---|
| List hosted zones | aws route53 list-hosted-zones |
| List records in a zone | aws route53 list-resource-record-sets --hosted-zone-id <ZONE-ID> |
| Create or update a record | aws route53 change-resource-record-sets --hosted-zone-id <ZONE-ID> --change-batch file://record.json |
| List health checks | aws route53 list-health-checks |
| Health check status | aws route53 get-health-check-status --health-check-id <ID> |
| Query a public resolver | dig api.example.com @8.8.8.8 |
| Show authoritative servers | dig NS example.com |
| Problem | Likely cause and fix |
|---|---|
| Change not visible | Old TTL still cached. Wait it out, and lower TTL before future changes. |
| NXDOMAIN for some users | No Geolocation Default record. Add one. |
| Failover does not happen | Health check not attached to the primary record. Attach it. |
| CNAME rejected at root | Zone apex limitation. Use an Alias record. |
| Private name will not resolve | VPC not associated with the private hosted zone. Associate it. |
| Healthy server shows Unhealthy | Checker IPs blocked by security group or firewall. Allow them. |