DNS and Route 53
Run public and private DNS on AWS with Route 53: hosted zones, alias records, all eight routing policies, health checks and failover — and shift traffic between two versions of an API with a C# tool.
Assumes: AWS CLI v2 · AWS SDK for .NET v4 (AWSSDK.Route53 4.1.1.2) · .NET 10 LTS · CDK v2 (Amazon.CDK.Lib 2.277.0) · Terraform AWS provider v6 · Region us-east-1. Verified against official sources on 2026-11-18.
Learning objectives
By the end of this lesson you can:
- Explain public and private hosted zones, how a VPC resolves names, and what split-horizon DNS is.
- Choose the right record type, including alias records, and explain why alias beats CNAME for AWS resources.
- Pick the right routing policy — simple, weighted, latency, failover, geolocation, geoproximity, IP-based, multivalue — for a scenario.
- Configure health checks, including for private resources that Route 53's health checkers cannot reach.
- Create a private hosted zone with the CLI, CDK and Terraform, and run a C# tool that shifts weighted traffic safely.
Prerequisites
- Networking refresher — how DNS resolution works, TTLs and record types.
- VPC fundamentals — the Amazon DNS resolver at VPC base + 2 and the
enableDnsSupport/enableDnsHostnamesattributes. - Tools: AWS CLI v2 (
learn-sandbox), .NET 10 SDK.
Why this matters in banking
DNS is in the critical path of every banking transaction. The mobile app resolves api.harbourline.example before it can authenticate; the payments service resolves the database endpoint before it can post a transaction; the core banking adaptor resolves on-premises names over a VPN. When DNS is wrong, everything looks broken at once.
DNS is also a resilience tool. Failover records, health checks and short TTLs are how many banks move customer traffic from a failing Region to a standby one — and regulators (for example, the UK's operational resilience rules for important business services) expect you to have tested that path. And DNS is a security surface: hijacked records, dangling CNAMEs pointing at deleted resources, and DNS used as an exfiltration channel are all real incident types.
Harbourline uses Route 53 for its public domains, private zones for internal service names in every VPC, failover between eu-west-2 and eu-west-1 for customer-facing APIs, and weighted records for gradual rollouts. This lesson covers all of it.
The idea in plain language
DNS translates names (api.harbourline.example) into addresses (203.0.113.10). Amazon Route 53 is AWS's DNS service. It does four jobs:
- Domain registration — buying and renewing domain names.
- Authoritative DNS — answering "what is the address of X?" for zones you own, in hosted zones.
- Health checking and traffic routing — answering differently depending on health, location, latency or weights.
- Resolution inside VPCs — the Route 53 Resolver at VPC base + 2 answers queries from your resources, including for private zones and, with endpoints and rules, for on-premises names.
Analogy: Route 53 is the bank's switchboard. The public hosted zone is the number printed on the website: anyone can call it. The private hosted zone is the internal extension list: it only works from phones inside the building (associated VPCs). Routing policies are the switchboard operator's rules — "send callers to the nearest branch", "send 10% of calls to the new team", "if the London office doesn't answer, put callers through to Dublin". Health checks are the operator ringing each office every 30 seconds to make sure someone picks up.
Hosted zones
| Public hosted zone | Private hosted zone | |
|---|---|---|
| Answers queries from | The internet | Only VPCs associated with the zone (any Region, any account with authorization) |
| Typical names | harbourline.example, api.harbourline.example | payments.internal.harbourline.example, db.learn.internal |
| Needs | Name server (NS) delegation at the registrar | VPC attributes enableDnsSupport and enableDnsHostnames = true |
| Price | USD 0.50 per zone per month (first 25), USD 0.10 after; free if deleted within 12 hours | Same zone price |
Split-horizon DNS: a public zone and a private zone can have the same name. Inside associated VPCs, the private zone wins; everyone else sees the public one. Harbourline uses this so api.harbourline.example resolves to an internal load balancer for staff and services in the VPC, and to the public edge for customers.
Record types you will use
| Type | Holds | Notes |
|---|---|---|
| A / AAAA | IPv4 / IPv6 address | |
| CNAME | Another name | Not allowed at the zone apex (harbourline.example itself) |
| Alias (Route 53 extension) | A pointer to an AWS resource: ELB, CloudFront, API Gateway, S3 website, another record in the zone… | Works at the apex; queries to alias records for AWS resources are free; follows the target's IP changes automatically |
| MX, TXT, CAA, SRV | Mail, verification, certificate authority restrictions, services | CAA limits which CAs may issue certificates for your domain — a cheap security win |
| NS, SOA | Delegation and zone metadata | Created with the zone |
The eight routing policies
| Policy | Answers with… | Private zones | Banking use |
|---|---|---|---|
| Simple | One record's value(s) | Yes | Most internal names |
| Weighted | Records in proportion to weights (e.g. 90/10) | Yes | Canary and blue/green releases |
| Latency | The Region with lowest latency for the resolver | Yes | Multi-Region active-active APIs |
| Failover | Primary while healthy, otherwise secondary | Yes | Active-passive DR between Regions |
| Geolocation | By the user's continent/country/subdivision | Yes | EU customers to the EU subsidiary's stack (data residency) |
| Geoproximity | By distance to resources, adjustable with a bias | Yes | Gradually shifting load between Regions |
| IP-based | By the client's source IP ranges (CIDR collections) | No (public zones only) | Routing a partner's or ISP's ranges to a specific endpoint |
| Multivalue answer | Up to eight healthy records, chosen at random | Yes | Simple client-side load spreading with health checks |
Policies can be nested with alias records: for example a failover record whose primary is a latency record set.
Health checks
Route 53 health checkers run from many locations on the internet. Three kinds:
- Endpoint — HTTP, HTTPS or TCP to an IP or domain name, optionally matching a string in the response.
- Calculated — combines other health checks ("healthy if at least 2 of 3 are healthy").
- CloudWatch alarm — healthy while an alarm is
OK. This is how you health-check private resources the internet can't reach: alarm on an internal metric (ALBHealthyHostCount, a synthetic canary) and attach the health check to the record.
For alias records pointing at a load balancer, set Evaluate target health = Yes instead of creating a separate health check: Route 53 then uses the load balancer's own target health.
Prices (checked 2026-11-18): basic health check USD 0.50 per month for AWS endpoints, USD 0.75 for non-AWS; optional features (HTTPS, string matching, fast interval, latency measurement) add USD 1.00 / USD 2.00 each per month.
Resolution inside a VPC
Resources in a VPC send DNS queries to the Route 53 Resolver (VPC base + 2, or 169.254.169.253). The Resolver answers, in order of specificity: Resolver forwarding rules (to on-premises DNS, covered in this module's hybrid connectivity lesson), private hosted zones associated with the VPC, VPC-internal names (ip-10-20-64-15.ec2.internal) and finally public DNS. Each network interface can send at most 1,024 packets per second to the Resolver — cache DNS answers in busy services.
What problem Route 53 solves
- Highly available authoritative DNS with a 100% availability SLA ⚠ VERIFY current SLA wording, anycast name servers, and no servers for you to run.
- Traffic management — health-aware, latency-aware and weighted answers, which are the backbone of multi-Region designs.
- Private naming for services across VPCs and accounts, without running your own DNS servers.
Sharp edges:
- DNS failover is only as fast as TTLs and client caches. A 300-second TTL means some clients keep using the old answer for five minutes or more; some client libraries and JVMs cache far longer. .NET's
HttpClientkeeps connections open — setSocketsHttpHandler.PooledConnectionLifetime(for example 1–5 minutes) so new DNS answers are actually used. - Health checks can't reach private IPs — use CloudWatch-alarm-based checks.
- Dangling records (a CNAME or alias to a deleted resource) can let someone else claim the target name — a known subdomain-takeover pattern. Delete records with their resources.
- Private hosted zones need the VPC DNS attributes; otherwise they silently don't resolve.
- Route 53 is a global service whose control plane is in us-east-1. For failover, rely on the data plane (health checks flipping answers), not on making API changes during an incident. Route 53 Application Recovery Controller adds highly available routing controls for that purpose.
Microsoft / Azure comparison
| You know (Microsoft/Azure) | AWS equivalent | What's different |
|---|---|---|
| Azure DNS (public zones) | Route 53 public hosted zone | Route 53 also registers domains and has alias records |
| Azure Private DNS zones + VNet links | Route 53 private hosted zone + VPC associations | Cross-account association needs an authorization step |
| Azure Traffic Manager (priority, weighted, performance, geographic, multivalue, subnet) | Route 53 routing policies (failover, weighted, latency, geolocation/geoproximity, multivalue, IP-based) | Built into the DNS service, not a separate product |
| Traffic Manager endpoint monitoring | Route 53 health checks | Route 53 adds calculated and CloudWatch-alarm checks |
| Alias record sets (to Azure resources) | Alias records | Both work at the apex; Route 53 alias queries to AWS resources are free |
| Azure DNS Private Resolver (inbound/outbound endpoints, forwarding rulesets) | Route 53 Resolver endpoints and rules | Very similar model |
| Azure Firewall DNS proxy / DNS filtering | Route 53 Resolver DNS Firewall | Domain allow/deny lists on the VPC resolver |
Architecture
Security-boundary view: the public zone is part of the internet-facing attack surface — protect it with IAM (few people may change records), DNSSEC signing, CAA records, and change monitoring through CloudTrail. The private zone is visible only to associated VPCs, so internal topology (database endpoints, internal service names) is not published to the internet. The VPC Resolver is a natural control point: Resolver query logging records every name looked up, and DNS Firewall can block known-bad or unexpected domains.
Step-by-step implementation
Create a private hosted zone associated with the lab VPC
learn.internal.harbourline.example, associated with hl-m02-vpc in us-east-1. Check the VPC's DNS attributes are on. Delete it within 12 hours and it is not charged.
Add simple records
db.learn.internal.harbourline.example → CNAME to an RDS endpoint (or any name, for practice); app.… → A record with a private IP.
Add a weighted pair for a canary
ledger.learn.internal.harbourline.example with two CNAME records: SetIdentifier=blue, Weight=100 → blue.…; SetIdentifier=green, Weight=0 → green.…. A weight of 0 means "never, unless all others are 0".
Shift traffic with the C# tool
Run the weight shifter to move to 90/10, then 50/50, then 0/100, waiting for INSYNC each time.
Design (on paper) the public failover record
Primary: alias to the eu-west-2 ALB, evaluate target health. Secondary: alias to the eu-west-1 ALB. Decide the TTL and what monitors the secondary.
AWS Console instructions
- Route 53 → Hosted zones → Create hosted zone. Domain
learn.internal.harbourline.example; Type: Private hosted zone; VPCs to associate: Region us-east-1,hl-m02-vpc; tags → Create. - In the zone → Create record → record name
ledger; type CNAME; valueblue.learn.internal.harbourline.example; TTL 60; Routing policy: Weighted; Weight 100; Record IDblue→ Add another record forgreenwith weight 0 → Create records. - Route 53 → Health checks → Create health check → State of CloudWatch alarm to monitor a private resource, or Endpoint for a public one.
- Route 53 → Resolver → Query logging to log VPC DNS queries to CloudWatch Logs or S3.
- To check a VPC's DNS attributes: VPC → Your VPCs → select → Details: DNS resolution and DNS hostnames both Enabled.
AWS CLI
$p = "--profile", "learn-sandbox", "--region", "us-east-1"
$vpcId = aws ec2 describe-vpcs --filters Name=tag:Name,Values=hl-m02-vpc @p --query "Vpcs[0].VpcId" --output text
# Private hosted zone (associating a VPC at creation makes it private)
$zoneId = aws route53 create-hosted-zone --name learn.internal.harbourline.example `
--vpc VPCRegion=us-east-1,VPCId=$vpcId --caller-reference "hl-m02-$(Get-Date -Format yyyyMMddHHmmss)" `
--hosted-zone-config Comment="Module 2 lab",PrivateZone=true @p `
--query "HostedZone.Id" --output text
$zoneId = $zoneId -replace "/hostedzone/", ""
aws route53 change-tags-for-resource --resource-type hostedzone --resource-id $zoneId `
--add-tags Key=Project,Value=cea-lab Key=Lab,Value=m02-secure-vpc Key=Environment,Value=learn Key=Owner,Value=alex @p
# Simple A record and a weighted pair, in one atomic change batch
$batch = @"
{
"Comment": "Lab records",
"Changes": [
{ "Action": "UPSERT", "ResourceRecordSet": { "Name": "app.learn.internal.harbourline.example", "Type": "A", "TTL": 60,
"ResourceRecords": [ { "Value": "10.20.64.10" } ] } },
{ "Action": "UPSERT", "ResourceRecordSet": { "Name": "ledger.learn.internal.harbourline.example", "Type": "CNAME", "TTL": 60,
"SetIdentifier": "blue", "Weight": 100, "ResourceRecords": [ { "Value": "blue.learn.internal.harbourline.example" } ] } },
{ "Action": "UPSERT", "ResourceRecordSet": { "Name": "ledger.learn.internal.harbourline.example", "Type": "CNAME", "TTL": 60,
"SetIdentifier": "green", "Weight": 0, "ResourceRecords": [ { "Value": "green.learn.internal.harbourline.example" } ] } }
]
}
"@
$batch | Out-File -Encoding ascii records.json
$changeId = aws route53 change-resource-record-sets --hosted-zone-id $zoneId --change-batch file://records.json @p --query "ChangeInfo.Id" --output text
aws route53 wait resource-record-sets-changed --id $changeId @p
# List records
aws route53 list-resource-record-sets --hosted-zone-id $zoneId @p `
--query "ResourceRecordSets[].[Name,Type,SetIdentifier,Weight,TTL]" --output table
# Ask Route 53 what it would answer (works for private zones too, without being inside the VPC)
aws route53 test-dns-answer --hosted-zone-id $zoneId --record-name ledger.learn.internal.harbourline.example --record-type CNAME @p
# Confirm the VPC DNS attributes private zones depend on
aws ec2 describe-vpc-attribute --vpc-id $vpcId --attribute enableDnsSupport @p
aws ec2 describe-vpc-attribute --vpc-id $vpcId --attribute enableDnsHostnames @ptest-dns-answer is the quickest way to debug routing policies: it shows the answer Route 53 would give, optionally for a given resolver IP or EDNS client subnet.
Infrastructure as Code
using Amazon.CDK;
using Amazon.CDK.AWS.EC2;
using Amazon.CDK.AWS.Route53;
using Constructs;
namespace Harbourline.Networking.Examples;
public sealed class DnsStack : Stack
{
public DnsStack(Construct scope, string id, IVpc vpc, IStackProps? props = null) : base(scope, id, props)
{
var zone = new PrivateHostedZone(this, "LearnZone", new PrivateHostedZoneProps
{
ZoneName = "learn.internal.harbourline.example",
Vpc = vpc,
Comment = "Module 2 lab",
});
_ = new ARecord(this, "App", new ARecordProps
{
Zone = zone,
RecordName = "app",
Target = RecordTarget.FromIpAddresses("10.20.64.10"),
Ttl = Duration.Seconds(60),
});
// Weighted pair: L2 record props accept Weight + SetIdentifier in recent CDK v2 releases.
_ = new CnameRecord(this, "LedgerBlue", new CnameRecordProps
{
Zone = zone,
RecordName = "ledger",
DomainName = "blue.learn.internal.harbourline.example",
Weight = 100,
SetIdentifier = "blue",
Ttl = Duration.Seconds(60),
});
_ = new CnameRecord(this, "LedgerGreen", new CnameRecordProps
{
Zone = zone,
RecordName = "ledger",
DomainName = "green.learn.internal.harbourline.example",
Weight = 0,
SetIdentifier = "green",
Ttl = Duration.Seconds(60),
});
Amazon.CDK.Tags.Of(this).Add("Project", "cea-lab");
Amazon.CDK.Tags.Of(this).Add("Lab", "m02-secure-vpc");
Amazon.CDK.Tags.Of(this).Add("Environment", "learn");
}
}For alias records to a load balancer, use RecordTarget.FromAlias(new LoadBalancerTarget(alb)) from Amazon.CDK.AWS.Route53.Targets.
Complete code
A weight shifter for canary releases. It reads the current weighted records for a name, validates the requested weights, UPSERTs them in one atomic change batch, and waits until Route 53 reports INSYNC on all its name servers.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AWSSDK.Route53" Version="4.1.1.2" />
<PackageReference Include="AWSSDK.SSO" Version="4.1.0.2" />
<PackageReference Include="AWSSDK.SSOOIDC" Version="4.1.0.2" />
</ItemGroup>
</Project>using Amazon;
using Amazon.Route53;
using Amazon.Route53.Model;
// Usage: dotnet run -- <hosted-zone-id> <record-name> blue=90 green=10
if (args.Length < 3)
{
Console.Error.WriteLine("Usage: WeightShift <zone-id> <record-name> <setId=weight> [<setId=weight> ...]");
return 2;
}
var zoneId = args[0];
var recordName = args[1].TrimEnd('.') + ".";
var requested = new Dictionary<string, long>(StringComparer.Ordinal);
foreach (var pair in args.Skip(2))
{
var parts = pair.Split('=', 2);
if (parts.Length != 2 || !long.TryParse(parts[1], out var w) || w is < 0 or > 255)
{
Console.Error.WriteLine($"Invalid weight '{pair}': use setId=0..255");
return 2;
}
requested[parts[0]] = w;
}
if (requested.Values.All(w => w == 0))
{
Console.Error.WriteLine("Refusing: all weights 0 makes Route 53 treat every record as equal weight.");
return 2;
}
// Route 53 is a global service; the SDK signs for us-east-1.
using var route53 = new AmazonRoute53Client(RegionEndpoint.USEast1);
// 1. Load the existing weighted records for this name (all types share the name, so filter).
var existing = new List<ResourceRecordSet>();
var list = await route53.ListResourceRecordSetsAsync(new ListResourceRecordSetsRequest
{
HostedZoneId = zoneId,
StartRecordName = recordName,
});
existing.AddRange((list.ResourceRecordSets ?? [])
.Where(r => r.Name == recordName && r.SetIdentifier is not null && r.Weight is not null));
if (existing.Count == 0)
{
Console.Error.WriteLine($"No weighted records found for {recordName} (results are limited to the first page).");
return 1;
}
var unknown = requested.Keys.Except(existing.Select(r => r.SetIdentifier!)).ToList();
if (unknown.Count > 0)
{
Console.Error.WriteLine($"Unknown set identifier(s): {string.Join(", ", unknown)}");
return 1;
}
// 2. Build one atomic change batch: every requested record is UPSERTed with its new weight.
var changes = new List<Change>();
foreach (var record in existing.Where(r => requested.ContainsKey(r.SetIdentifier!)))
{
Console.WriteLine($"{record.SetIdentifier,-10} {record.Weight,4} -> {requested[record.SetIdentifier!],4}");
record.Weight = requested[record.SetIdentifier!];
changes.Add(new Change { Action = ChangeAction.UPSERT, ResourceRecordSet = record });
}
var total = existing.Sum(r => r.Weight ?? 0);
foreach (var record in existing)
{
Console.WriteLine($" {record.SetIdentifier}: {100.0 * (record.Weight ?? 0) / total:N1}% of answers");
}
var response = await route53.ChangeResourceRecordSetsAsync(new ChangeResourceRecordSetsRequest
{
HostedZoneId = zoneId,
ChangeBatch = new ChangeBatch
{
Comment = $"Weight shift {string.Join(" ", args.Skip(2))} by {Environment.UserName}",
Changes = changes,
},
});
// 3. Wait until the change has reached all Route 53 authoritative servers.
var changeId = response.ChangeInfo.Id;
var status = response.ChangeInfo.Status;
var deadline = DateTime.UtcNow.AddMinutes(5);
while (status != ChangeStatus.INSYNC && DateTime.UtcNow < deadline)
{
await Task.Delay(TimeSpan.FromSeconds(5));
status = (await route53.GetChangeAsync(new GetChangeRequest { Id = changeId })).ChangeInfo.Status;
Console.WriteLine($" change {changeId}: {status}");
}
if (status != ChangeStatus.INSYNC)
{
Console.Error.WriteLine("Timed out waiting for INSYNC — check the change in the console before shifting further.");
return 1;
}
Console.WriteLine($"Done. Clients see the new split within the record TTL ({existing[0].TTL} s) plus their own caching.");
return 0;> dotnet run -- Z0123456789ABCDEFGHIJ ledger.learn.internal.harbourline.example blue=90 green=10
blue 100 -> 90
green 0 -> 10
blue: 90.0% of answers
green: 10.0% of answers
change /change/C0987654321ZYXWVUTSRQ: INSYNC
Done. Clients see the new split within the record TTL (60 s) plus their own caching.Code explained line by line
recordName = args[1].TrimEnd('.') + "."— Route 53 returns fully qualified names with a trailing dot; normalising avoids "not found" surprises.w is < 0 or > 255— Route 53 weights are integers from 0 to 255.- "all weights 0" check — if every record in a weighted set has weight 0, Route 53 returns them all with equal probability. That is never what a canary operator means.
new AmazonRoute53Client(RegionEndpoint.USEast1)— Route 53 is global; its API is signed for us-east-1 regardless of where your workloads run.ListResourceRecordSetsAsync(... StartRecordName = recordName)— lists records starting at that name; the filter keeps only weighted records (SetIdentifierandWeightboth set) with exactly that name. Large zones would need paging withNextRecordName; the message says so.record.Weight = ...thenChangeAction.UPSERT— reusing the full existingResourceRecordSetkeeps every other field (TTL, values, health check ID) unchanged. UPSERT creates or replaces.- One
ChangeBatchwith all changes — Route 53 applies a batch atomically: either every weight changes or none does. Two separate calls could leave a moment with an unintended split. Comment = ... by {Environment.UserName}— the comment appears in the change record; CloudTrail records the caller identity as well.GetChangeAsyncuntilChangeStatus.INSYNC—PENDINGmeans not all authoritative servers have the change yet. Only afterINSYNC+ TTL can you judge the canary's metrics.
Security considerations
- Least privilege on DNS. Only the pipeline role should have
route53:ChangeResourceRecordSets, ideally scoped with conditions on record names and types (route53:ChangeResourceRecordSetsNormalizedRecordNames) ⚠ VERIFY condition key names in the Route 53 IAM reference. - DNSSEC signing for public zones (with a KMS asymmetric key in us-east-1) protects customers from spoofed answers; monitor the DNSSEC CloudWatch metrics so a key problem doesn't take the domain offline.
- CAA records restrict which certificate authorities may issue for your domains (for example only Amazon's CA for ACM).
- Avoid dangling records. Delete DNS records in the same change as the resources they point to; scan regularly for CNAMEs to non-existent targets.
- Log and filter queries. Resolver query logging plus Route 53 Resolver DNS Firewall (allow-list of domains for sensitive VPCs) detect and block DNS-based exfiltration and malware callbacks.
- Private zones keep topology private. Never publish internal names (database endpoints, internal service names) in public zones.
⚠ Learning shortcut — not for production
The lab creates a private zone in your account, associated with one VPC, and changes records with a CLI and a C# tool you run yourself. In production at Harbourline, private zones live in a central networking account and are associated with workload VPCs across accounts (with association authorizations), records change only through pipelines with approvals, and public zones are DNSSEC-signed with change alerts sent to the security operations team.
Banking use case
Customer API failover (eu-west-2 → eu-west-1). api.harbourline.example is a failover record: PRIMARY is an alias to the London ALB with evaluate target health; SECONDARY is an alias to the Dublin ALB. A calculated health check on the primary combines the ALB's target health with a CloudWatch alarm on an internal synthetic transaction (log in, fetch balance) — so London fails over when customers can't actually transact, not only when servers are down. TTL is 60 seconds; the mobile app's .NET MAUI client uses PooledConnectionLifetime = 2 minutes. Failover is tested quarterly as part of the operational-resilience programme (Module 12: HA & DR).
EU data residency. Requests from EU countries are routed with a geolocation record to the EU subsidiary's stack in eu-west-1; a default geolocation record catches locations that don't match any rule. Whether DNS-level routing is a sufficient residency control is a legal and compliance question — it's one layer, alongside where data is actually stored.
Internal canaries. The ledger service is released by shifting weighted records 0 → 5 → 25 → 100 with the weight shifter, watching error rates between steps.
Common mistakes
- CNAME at the zone apex → not allowed → use an alias record.
- Private zone doesn't resolve → VPC not associated, or
enableDnsSupport/enableDnsHostnamesoff → associate and enable both. - Health check on a private IP → always unhealthy, because checkers are on the internet → CloudWatch-alarm health check.
- Long TTLs on failover records → failover takes hours for some clients → 60 seconds or less on records that must move.
- Geolocation without a default record → clients from unmatched locations get no answer → always add a default.
- Ignoring client-side caching →
HttpClientkeeps using the old IP over a pooled connection → setPooledConnectionLifetime.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
NXDOMAIN inside the VPC for a private record | Zone not associated with this VPC, or VPC DNS attributes off | aws route53 get-hosted-zone shows VPCs; enable DNS attributes |
| Public name doesn't resolve after creating the zone | Registrar NS records don't match the zone's NS set | Update the registrar's name servers to the four in the zone |
InvalidChangeBatch: ... CNAME ... conflicts | CNAME and another record at the same name | A CNAME must be the only record at its name |
| Failover never happens | No health check on the primary, or evaluate target health off | Attach a health check / enable target health evaluation |
| Weighted record gets all traffic despite weight 10 | Other records unhealthy (unhealthy records are excluded) | Check health check status for every set |
| Resolver throttling / intermittent DNS timeouts under load | Over 1,024 packets per second per ENI to the Resolver | Cache DNS; reuse connections; spread load across ENIs |
| Cross-account VPC association fails | No association authorization from the zone owner | create-vpc-association-authorization in the zone's account, then associate-vpc-with-hosted-zone in the VPC's account |
Cost and cleanup
Cost label: credits. A hosted zone deleted within 12 hours of creation is not charged (queries still are). Queries from inside the VPC to a private zone in this lab: a few hundred, so effectively USD 0.00 at USD 0.40 per million. If you keep the zone: USD 0.50 per month. Health checks (if you try one): USD 0.50–0.75 per month, billed proportionally ⚠ VERIFY proration for short-lived checks. Free alternative: design-only — write the record sets and routing policies in Terraform without applying.
$p = "--profile", "learn-sandbox", "--region", "us-east-1"
# A zone can only be deleted when it contains just its NS and SOA records
$sets = aws route53 list-resource-record-sets --hosted-zone-id $zoneId @p --output json | ConvertFrom-Json
$deletes = $sets.ResourceRecordSets | Where-Object { $_.Type -notin "NS", "SOA" } |
ForEach-Object { @{ Action = "DELETE"; ResourceRecordSet = $_ } }
if ($deletes) {
@{ Changes = @($deletes) } | ConvertTo-Json -Depth 10 | Out-File -Encoding ascii delete.json
aws route53 change-resource-record-sets --hosted-zone-id $zoneId --change-batch file://delete.json @p
}
aws route53 delete-hosted-zone --id $zoneId @p
Remove-Item records.json, delete.json -ErrorAction SilentlyContinue
# Any health checks left?
aws route53 list-health-checks @p --query "HealthChecks[].[Id,HealthCheckConfig.Type]" --output tableExercises
- 🟢 Guided: Create the private zone, the A record and the weighted pair; use
test-dns-answerseveral times to seebluereturned; run the weight shifter to 50/50 and repeat. Delete the zone within 12 hours. - 🟡 Challenge: Design the record sets (Terraform, not applied) for
api.harbourline.example: failover between eu-west-2 and eu-west-1, where the primary is itself a weighted pair (blue/green) in eu-west-2. Include the health checks and explain how a blue-only outage is handled. - 🔴 Live problem: "We failed over the customer API to Dublin at 10:02 during the DR test. Route 53 shows the secondary answer since 10:03, but 30% of mobile traffic was still hitting London at 10:30." Explain the likely causes and the fixes for the next test.
Assignment
Write a DNS runbook for one Harbourline service: zones and records (with TTLs and why), routing policy, health checks, who may change what, how a failover is triggered and verified, and the rollback. Add the weight shifter to your repository as tools/weight-shift/ and reference it from the runbook.
Solutions
With weights 100/0, test-dns-answer always returns blue.learn.internal.harbourline.example. After blue=50 green=50, repeated calls return each about half the time. Why: weighted answers are chosen per query in proportion to weight / total weight; 0 means "only if all are 0". Remember to empty and delete the zone — the cleanup script deletes every record except NS and SOA first, because Route 53 refuses to delete non-empty zones.
Create two weighted alias records api-ew2.harbourline.example (blue → blue ALB, green → green ALB, both with evaluate target health). Then api PRIMARY failover alias → api-ew2.harbourline.example (evaluate target health = true); SECONDARY failover alias → Dublin ALB. If blue's targets are unhealthy, the weighted set returns only green; the primary stays healthy because at least one weighted record is healthy. Only when both blue and green are unhealthy does the primary count as unhealthy and the failover answer switch to Dublin. Why nesting: each layer answers one question — "which version?" then "which Region?".
Route 53 changed its answer, so the remaining London traffic is client-side caching: (1) record TTL — if the record or a parent CNAME had a long TTL, resolvers keep the old answer; (2) connection reuse — the mobile backend-for-frontend and partners using HttpClient keep pooled connections to London's IPs indefinitely unless PooledConnectionLifetime is set; (3) ISP resolvers that ignore TTLs; (4) London still accepted traffic — failover changes DNS, it doesn't stop London. Fixes: 60-second TTLs on every record in the chain, PooledConnectionLifetime in all .NET clients, and in the runbook also drain London (ALB listener returns 503 or targets deregistered) once DNS has moved.
Knowledge check
Answer: Alias works at the zone apex, follows the ALB's changing IPs, can evaluate target health, and queries to alias records for AWS resources are free. CNAMEs can't be at the apex and cost a normal query.
Answer: Create a CloudWatch alarm on an internal signal (for example ALB HealthyHostCount or a canary metric) and a Route 53 health check of type "CloudWatch alarm" on it.
Answer: Route 53 returns all records with equal probability.
Answer: The private zone's records. If a name exists only in the public zone, the instance gets NXDOMAIN — the private zone takes over the whole namespace inside the VPC.
Answer: Latency-based routing. Geolocation routes by user location; geoproximity by distance with a bias.
Interview questions
- "How would you implement active-passive DR for an API with Route 53?" — Failover records: primary alias to the main Region's ALB with target health (and a health check on a real transaction), secondary alias to the standby; short TTLs; clients that recycle connections; tested regularly.
- "What's split-horizon DNS and why would a bank use it?" — Same zone name in a public and a private hosted zone; internal clients get private answers, internet clients public ones; keeps internal topology private and traffic on private paths.
- "How do you resolve on-premises names from a VPC, and VPC names from on-premises?" — Route 53 Resolver outbound endpoints with forwarding rules, and inbound endpoints that on-premises DNS forwards to.
- "What's a dangling DNS record?" — A record pointing to a resource you deleted; if someone else can claim that resource name, they can serve content on your domain. Delete records with resources and scan for them.
Certification practice
A bank runs an API behind an Application Load Balancer in eu-west-2 and a standby copy in eu-west-1. Traffic must go to eu-west-1 only if the eu-west-2 deployment is unhealthy. What should the solutions architect configure?
A. Weighted records with weights 100 and 0 B. Failover records: primary alias to the eu-west-2 ALB with evaluate target health enabled, secondary alias to the eu-west-1 ALB C. Latency records for both Regions D. A multivalue answer record with both ALBs
Answer: B. Failover routing is designed for active-passive. A doesn't switch on health unless health checks exclude the primary, and weight 0 only serves when everything else is unhealthy — workable but not the intended pattern. C sends traffic to both Regions. D also spreads traffic across both.
A CloudOps engineer creates a private hosted zone and associates it with a VPC. Instances in the VPC can't resolve records in the zone. What is the most likely cause?
A. The zone needs a public NS delegation
B. The VPC's enableDnsHostnames or enableDnsSupport attribute is disabled
C. Private hosted zones need a Resolver inbound endpoint
D. Security groups block UDP 53 to the resolver
Answer: B. Private zones require both attributes. A applies to public zones. C is only needed for on-premises clients. D — traffic to the Amazon resolver isn't filtered by security groups.
A company has identical stacks in us-east-1, eu-west-2 and ap-southeast-2 and wants each user served by the stack that gives them the best response time, while avoiding unhealthy stacks. Which configuration is best?
A. Geolocation records by continent B. Latency records with health checks for each Region C. Weighted records with equal weights D. Simple routing with three IP addresses
Answer: B. Latency routing answers with the lowest-latency Region for the resolver; health checks remove unhealthy Regions. A approximates by location, which isn't the same as latency. C spreads randomly. D can't do health-based or latency-based selection.
A security team suspects malware in a VPC is sending data out through DNS queries to an attacker-controlled domain. Workloads only need to resolve AWS service names and three partner domains. What should the security engineer implement?
A. A network ACL blocking UDP 53 outbound B. Route 53 Resolver DNS Firewall with an allow list for the required domains and a block rule for everything else, plus Resolver query logging C. A security group rule blocking port 53 D. DNSSEC signing on the company's public zone
Answer: B. DNS Firewall filters queries at the VPC resolver, and query logs provide evidence. A and C don't apply — traffic to the Amazon resolver isn't filtered by NACLs or security groups. D protects the authenticity of your own zone's answers, not outbound queries.
Completion checklist
- I can explain public vs private hosted zones and split-horizon DNS
- I can pick a routing policy for a scenario and explain alias vs CNAME
- I created a private zone, records and a weighted pair (or designed them in Terraform)
- I ran the weight shifter and saw
INSYNC - I deleted the zone within 12 hours and checked for leftover health checks
Key takeaways
- Route 53 provides public and private authoritative DNS, health checks and traffic routing; the VPC Resolver answers your resources' queries.
- Alias records are free for AWS targets, work at the apex and follow target health.
- Eight routing policies cover canaries (weighted), DR (failover), performance (latency) and residency (geolocation).
- Health checkers live on the internet — use CloudWatch-alarm checks for private resources.
- DNS changes are only as fast as TTLs and client connection reuse; secure DNS with least privilege, DNSSEC, CAA, query logging and DNS Firewall.
Further reading
- What is Amazon Route 53?
- Choosing a routing policy
- Working with private hosted zones
- Choosing between alias and non-alias records
- Amazon Route 53 pricing
Next: Elastic Load Balancing.
Independent learning resource — not affiliated with, endorsed or sponsored by Amazon Web Services. AWS and related marks are trademarks of Amazon.com, Inc. or its affiliates. All banking data in examples is fictional. Sample architectures are for learning and are not automatically compliant with GDPR, PCI DSS or any banking regulation.
VPC endpoints and PrivateLink
Reach S3, DynamoDB and other AWS APIs without the internet using gateway and interface endpoints, lock them down with endpoint and bucket policies, publish your own service privately with PrivateLink, and audit endpoint policies with C#.
Elastic Load Balancing: ALB, NLB and Gateway Load Balancer
Choose between Application, Network and Gateway Load Balancers, configure listeners, rules, target groups, health checks and TLS termination, make ASP.NET Core behave correctly behind a load balancer, and audit load balancers with C#.