Learning center

Same hostname, different answer inside and outside the network

When a name has a private and a public version, the answer depends on which resolver the client asks and which zones that resolver consults. A service that reaches the public address of an internal dependency, or a private address it cannot route to, is usually on a different resolver path than you tested. Query the same name through each path the service can use, compare the answers and the zone named in each SOA, then read the zones and forwarding rules that explain the difference.

The symptom#

Split-horizon DNS, which Route 53 calls split-view DNS, serves different records for the same name to internal and external clients. It is deliberate, and it produces confusing incidents when a client ends up on the wrong side: Route 53 split-view DNS

  • From your laptop api.example.com returns 203.0.113.10, and from the orders task it returns 10.0.30.5. You tested the wrong one.
  • A service in a new VPC or project gets the public address of an internal API and times out at a firewall, or reaches it through the internet with the wrong certificate.
  • On-premises clients that forward to the cloud get a different answer than cloud workloads, or SERVFAIL.

Each has the same root: two resolvers, two sets of zones.

Where the paths diverge#

On AWS, the VPC resolver uses a private hosted zone only for VPCs associated with it, picks the most specific matching private zone, and goes to public DNS only when no private zone matches. A Resolver forwarding rule for the domain, associated with the VPC, takes precedence over a private zone and sends the query to the rule's targets. Forwarding rules apply to the domain and all of its subdomains unless a system rule carves a subdomain out. Private hosted zone considerations · Resolver rules

On Google Cloud, a VM that uses the metadata server, 169.254.169.254, as its name server gets answers in a fixed order: an outbound server policy's alternative name servers, then response policies, then private, forwarding and peering zones authorized for the VPC network by longest suffix match, then Compute Engine internal names, and only then public DNS. A matching private zone without the record returns NXDOMAIN, and a forwarding zone whose targets do not respond returns SERVFAIL. Cloud DNS name resolution order

Off the cloud network, a laptop, a CI runner or an on-premises server uses its own resolver. It sees only public zones unless it forwards to an inbound endpoint or a VPN pushes an internal resolver.

Query each path#

From each place that matters, ask for the same name and type, and keep the status, the answer and the SOA of negative answers. dig manual

# Inside the service's container: the resolver it really uses
cat /etc/resolv.conf
getent ahosts api.example.com
dig @RESOLVER_IP api.example.com A

# The cloud resolver directly, from a host in the same network
dig @169.254.169.253 api.example.com A   # AWS VPC resolver
dig @169.254.169.254 api.example.com A   # Google Cloud metadata server

# The public authority, bypassing every private view
dig api.example.com NS +short
dig @PUBLIC_AUTHORITATIVE_NS api.example.com A +norecurse

Then read the zones and rules behind each answer. On AWS, list-hosted-zones-by-vpc lists the private zones a VPC uses, and the Resolver rule calls show which domains are forwarded. Private zone checks

On Google Cloud, list the zones and policies, then read a zone's visibility and privateVisibilityConfig to see whether it is private and which networks it serves. managed-zones list · managed-zones describe · ManagedZone resource · policies list

gcloud dns managed-zones list --project PROJECT
gcloud dns managed-zones describe ZONE --project PROJECT
gcloud dns record-sets list --project PROJECT --zone ZONE --name api.example.com. --type A
gcloud dns policies list --project PROJECT

Read the result#

Service's resolverYour testPoints to
Public addressPrivate addressThe service's network does not see the private zone
Private address, unreachablePrivate addressDNS is right; routing or firewall to that address
NXDOMAIN, SOA of a private zonePublic addressA private zone claims the name and lacks the record
SERVFAILAnswerA forwarding rule or zone whose targets do not answer
Same answerSame answerNot split-horizon; look at caches or the connection

The SOA in a negative answer is the quickest tell. It names the zone the resolver consulted, which may be a private zone you forgot existed.

A worked example: one name, two paths#

This example is illustrative. payments.example.com has a public record, 203.0.113.25, behind an internet-facing load balancer, and a private record, 10.0.40.8, in a private hosted zone example.com associated with the production VPC. The checkout service in a new VPC times out calling it, while everyone testing from the office gets a fast response.

PathAnswer
Laptop on office network203.0.113.25
checkout task, VPC resolver203.0.113.25
Production VPC host, VPC resolver10.0.40.8

The new VPC is not associated with the private zone, so its resolver goes to public DNS and returns the internet address. The new VPC's security groups and route table allow only private egress, so the connection times out. DNS is answering correctly for that VPC; the fix is either the association or an egress path, depending on which address checkout should use.

In a second case, checkout gets SERVFAIL for ledger.corp.example.com while the production VPC gets an answer. The new VPC has a Resolver rule forwarding corp.example.com. to on-premises servers whose firewall does not yet allow the new outbound endpoint's addresses. The zone is fine; the forwarding path is not. Outbound endpoints need TCP and UDP on port 53 in their security group. Resolver outbound endpoints

Limits#

dig from a bastion shows the bastion's view. Containers can use a different resolver, such as CoreDNS with its own forward rules, so the container's own resolv.conf and getent are the evidence that counts.

Resolvers cache, so a path that was fixed may keep serving the old answer until its TTL or negative TTL runs out. Negative caching after a new record

A right address can still fail at TLS when the private and public endpoints present different certificates. TLS hostname mismatch For the method across dependency layers, see runtime dependency failures.

Questions#

What is split-horizon DNS?

The same domain served with different records to different clients, usually a private zone for internal networks and a public zone for the internet. Route 53 calls it split-view DNS and builds it from a public and a private hosted zone with the same name.

Why does my laptop get a different IP than the server?

They ask different resolvers. The server's resolver consults private zones associated with its network; your laptop's resolver sees only public DNS unless a VPN or forwarder gives it the internal view.

Can a private zone hide public names?

Yes. On both AWS and Google Cloud, a private zone that matches a name answers for it, and a name missing from that zone returns NXDOMAIN instead of the public record. Route 53 can retry public DNS only when public DNS fallback is enabled for the zone.

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