Sub topic 4
Delegating your domain to Route 53 name servers
This chapter assumes you know what a hosted zone is, can run the AWS CLI, and understand that a registrar holds a domain's registration while a DNS service answers queries for it. Delegation is the step that connects the two. Until you do it, a hosted zone you created in Route 53 receives no traffic.
What delegation means
Creating a public hosted zone gives you four name servers and an NS record set. Resolvers on the internet don't know about them yet. They learn which servers are authoritative for example.com from the parent zone, .com, which stores NS records that point to your name servers. The registrar updates those records for you. This hand-off is the delegation.
If the NS records in .com don't match your hosted zone, resolvers ask the wrong servers and get no useful answer.
Find your zone's name servers
Create the zone and read its NS record set. Replace ZONE_ID with the ID returned by the first command.
aws route53 create-hosted-zone \
--name example.com \
--caller-reference "$(date +%s)"
aws route53 list-resource-record-sets \
--hosted-zone-id ZONE_ID \
--query "ResourceRecordSets[?Type=='NS']"The output lists four names such as ns-123.awsdns-45.com. Each hosted zone gets its own set, drawn from different top-level domains for resilience. Two hosted zones for the same domain have different name servers. Copy the set from the zone you intend to use.
Point the registrar at Route 53
Where you do this depends on where the domain is registered.
| Situation | What to do |
|---|---|
| Domain registered with Route 53 | Edit the registered domain's name servers to match the hosted zone's four values. Route 53 sets them automatically only if you created the zone through the registration flow. |
| Domain registered elsewhere | In the other registrar's console, replace its name servers with the four from your hosted zone. |
| Subdomain such as `dev.example.com` | Leave the registrar alone. Add an NS record named `dev.example.com` to the parent zone, with the subdomain zone's four name servers as values. |
Enter the names without a trailing dot unless the registrar requires one. Use all four servers, so that losing one doesn't take the domain offline.
Verify the delegation
Query the parent's view first, then query one of your name servers directly.
dig NS example.com +short
dig @ns-123.awsdns-45.com www.example.com A +norecurseThe first command should print exactly the four servers from your hosted zone. Use one of your own name servers in the second command. A response with the aa (authoritative answer) flag shows that the zone is loaded and answering.
Timing and caching
Registries publish NS changes within minutes to a few hours. The old NS records may stay in resolver caches for as long as their TTL, which is often 48 hours (172800 seconds) for NS records at the top-level domain. Don't expect an instant switch.
To make a migration safer:
- Create the hosted zone and copy every existing record into it before you change the name servers.
- Lower the TTL of the old NS record set at the current DNS provider a day or two ahead, if it allows that.
- Change the name servers at the registrar.
- Keep the old zone running until the old TTL has passed.
Copying records first matters because the moment resolvers see the new delegation, Route 53 answers for the whole domain. A missing MX or TXT record means lost mail or failed verification.
Common errors
- Wrong zone's name servers: the registrar lists servers from a deleted or duplicate zone.
dig NS example.com +shortshows values that differ fromlist-resource-record-sets. - SERVFAIL or lame delegation: the delegation points at servers that don't host the zone. Check that the zone exists and the name servers are spelled correctly.
- Edited the zone's NS record instead of the registrar: changing the NS record inside the hosted zone doesn't alter the parent's delegation.
- Subdomain not resolving: the parent zone has no NS record for the child zone.
Exercise
You moved example.com to Route 53 and added all records to the new hosted zone, but a colleague's resolver still returns the old provider's answers a few hours later. dig @ns-123.awsdns-45.com www.example.com A +norecurse returns the correct address. What is the most likely cause, and what should you check?
Show answer
The Route 53 zone is correct, so the problem is delegation or caching. Run dig NS example.com +short to see which name servers the parent zone returns. If they are the old provider's, the registrar change wasn't saved, so fix it there. If they are Route 53's, the colleague's resolver is serving cached NS records within their TTL (up to 48 hours), so wait for expiry.