Learning center

Route 53 private hosted zone names do not resolve from a VPC

A private hosted zone answers only queries that reach the VPC resolver from a VPC associated with the zone, with DNS support and DNS hostnames turned on. Check four things in order: the association, the two VPC DNS attributes, the resolver the instances actually use, and any Resolver rule or more specific zone that claims the name first. Each is a read-only API call.

The symptom#

A service in a VPC cannot resolve orders-db.example.internal. The record is in a private hosted zone, and the Route 53 console shows it. Typical forms:

  • NXDOMAIN from the VPC resolver, or the public answer for the name instead of the private one.
  • An answer from some VPCs and not others, such as a new VPC created for a migration.
  • Answers that changed after someone added a Resolver rule or a second private zone.

How the VPC resolver picks a source#

Private hosted zones need both enableDnsHostnames and enableDnsSupport set to true in the VPC. The resolver answers at 169.254.169.253 and at the base of the VPC's primary IPv4 range plus two. Private hosted zone considerations · Amazon DNS server

For a query from an associated VPC, the resolver looks for a private zone whose name matches the queried name or is a parent of it, and picks the most specific one. If the matching zone has no such name, it returns NXDOMAIN and does not retry against public DNS, unless public DNS fallback is enabled for that zone. If the name exists without the requested type, it returns NODATA. Only when no private zone matches does it resolve the name publicly. Overlapping namespaces

Two things can take the query away before any of that:

Check the configuration#

List the private zones associated with the VPC, and the VPCs associated with the zone. list-hosted-zones-by-vpc · get-hosted-zone

aws route53 list-hosted-zones-by-vpc \
  --profile PROFILE --vpc-id VPC_ID --vpc-region REGION \
  --query 'HostedZoneSummaries[].{id:HostedZoneId,name:Name}' --output table --no-cli-pager

aws route53 get-hosted-zone \
  --profile PROFILE --id ZONE_ID \
  --query '{name:HostedZone.Name,private:HostedZone.Config.PrivateZone,vpcs:VPCs}' --output json --no-cli-pager

Read the two DNS attributes. The call takes one attribute at a time. describe-vpc-attribute

aws ec2 describe-vpc-attribute --profile PROFILE --region REGION --vpc-id VPC_ID --attribute enableDnsSupport --no-cli-pager
aws ec2 describe-vpc-attribute --profile PROFILE --region REGION --vpc-id VPC_ID --attribute enableDnsHostnames --no-cli-pager

Read the DHCP options set attached to the VPC. AmazonProvidedDNS in domain-name-servers means instances use the VPC resolver. describe-vpcs · describe-dhcp-options

aws ec2 describe-vpcs --profile PROFILE --region REGION --vpc-ids VPC_ID \
  --query 'Vpcs[0].DhcpOptionsId' --output text --no-cli-pager

aws ec2 describe-dhcp-options --profile PROFILE --region REGION --dhcp-options-ids DHCP_OPTIONS_ID \
  --query 'DhcpOptions[0].DhcpConfigurations' --output json --no-cli-pager

List the Resolver rules associated with the VPC and the domains they claim. list-resolver-rule-associations · list-resolver-rules

aws route53resolver list-resolver-rule-associations \
  --profile PROFILE --region REGION --filters Name=VPCId,Values=VPC_ID \
  --query 'ResolverRuleAssociations[].ResolverRuleId' --output text --no-cli-pager

aws route53resolver list-resolver-rules \
  --profile PROFILE --region REGION \
  --query 'ResolverRules[].{id:Id,domain:DomainName,type:RuleType,targets:TargetIps[].Ip}' --output json --no-cli-pager

Finally, ask the resolver from inside the VPC and read the SOA in any negative answer. It names the zone that answered. dig manual

cat /etc/resolv.conf
dig @169.254.169.253 orders-db.example.internal A

Read the result#

FindingPoints to
Zone missing from list-hosted-zones-by-vpcThe VPC is not associated with the zone
Either DNS attribute falseThe VPC resolver does not serve private zones here
DHCP options list other serversInstances ask a custom resolver, which must forward the name
A forwarding rule for the domain or a parentThe rule wins; the query goes to its targets
NXDOMAIN with the SOA of a more specific zoneThat zone claims the name and lacks the record
NXDOMAIN with the SOA of the expected zoneThe record is missing or misspelled in the zone

A record created just before a failed lookup can also stay NXDOMAIN for the negative TTL. Negative caching after a new record

A worked example: one zone, two failures#

This example is illustrative. Account 111122223333 has a private zone example.internal with orders-db.example.internal at 10.0.14.21. The checkout service moves to a new VPC, vpc-0new, and its lookups return the public NXDOMAIN for example.internal.

list-hosted-zones-by-vpc for vpc-0new returns no zones. get-hosted-zone lists only vpc-0old under VPCs. Both DNS attributes are true, and the DHCP options show AmazonProvidedDNS. No private zone matches the name in the new VPC, so the resolver went to public DNS, where the name does not exist. The fix is to associate vpc-0new with the zone.

A month later, lookups of the same name from vpc-0old start going to the on-premises DNS servers, which do not know it. list-resolver-rule-associations shows a new rule on vpc-0old, and list-resolver-rules shows it as a FORWARD rule for example.internal. with two on-premises targets. The rule takes precedence over the private zone. Either the on-premises servers need the record, or a system rule for the private names needs to keep them in the VPC. Resolver rules

Limits#

get-hosted-zone lists the VPCs associated directly with the zone and does not reflect associations made through Route 53 Profiles. If your organization uses Profiles, check those associations too. get-hosted-zone

The checks read configuration in one account and Region. A zone owned by another account can still be associated with your VPC; list-hosted-zones-by-vpc shows it with its owner regardless of which account owns it. list-hosted-zones-by-vpc

On Kubernetes, pods ask CoreDNS, which forwards to the VPC resolver. A CoreDNS stub domain or forward block for the same domain changes the answer before the VPC sees the query. For the same name answering differently by path, see split-horizon DNS. For the method across dependency layers, see runtime dependency failures.

Questions#

Why does a private zone name return the public answer?

Because no private zone associated with this VPC matches the name, so the resolver resolved it publicly. Check the association with list-hosted-zones-by-vpc and confirm the instances use the VPC resolver.

Why does a name outside my private zone return NXDOMAIN?

A private zone for a parent domain claims every name under it. If example.com is a private zone in the VPC, www.example.com is answered from it and returns NXDOMAIN when it is not there, unless public DNS fallback is enabled for the zone.

Do I need both DNS attributes turned on?

Yes. AWS requires both enableDnsSupport and enableDnsHostnames to be true for private hosted zones.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading