Split-Horizon DNS: Different Answers Inside and Outside
See why networks give one name two answers, how split-horizon DNS is built and which traps catch laptops, VPNs and browsers.
Key takeaways
- Split-horizon DNS answers the same name differently for internal and external clients.
- It is usually built with a separate internal resolver, with server "views" or with a cloud provider's private zones.
- Records that exist publicly must be copied into the internal zone, or inside users will not find them.
- VPN settings and browsers using their own encrypted DNS are common reasons internal clients get the public answer.
Split-horizon DNS means the same name gets a different answer depending on who asks. Someone inside the office who looks up files.example.com receives a private address such as 10.0.0.20, while someone outside receives a public address, or learns that the name does not exist.
It is a practical way to keep internal traffic internal and to avoid publishing details of your network. It also adds a second version of the truth that you have to maintain, so it pays to know when you really need it.
The problem it solves
Imagine a company web application. Outside users reach it through a public address on the firewall, which forwards traffic to a server on a private network. Inside users sit on the same network as that server.
If inside users receive the public address, their traffic has to go to the firewall and be turned back inward. This is called hairpinning or NAT loopback, and not every device handles it well. Even when it works, the traffic takes a needless detour and the server may see all internal users as one address. Giving inside users the private address sends them straight there. Background on the two kinds of address is in public vs. private IP addresses.
Other common reasons:
- Hiding internal names such as database or management hosts from the public.
- Pointing internal users at a local copy of a service for speed.
- Reaching cloud services privately, where a provider's service name resolves to a private endpoint inside your virtual network.
- Applying different policies to guests and staff.
How it is built
A separate internal resolver
The simplest design uses two unrelated systems. Your public DNS host publishes the outside records. A DNS server on your network, which internal clients are told to use, holds its own copy of the zone with internal answers and forwards everything else to an upstream resolver.
Many routers offer a light version, often called host overrides or static DNS entries, that suits a home lab.
Views on one server
Some server software can choose which zone data to present based on the client's address. In BIND this is the view feature. A trimmed example:
acl internal { 10.0.0.0/8; 192.168.0.0/16; localhost; };
view "inside" {
match-clients { internal; };
recursion yes;
zone "example.com" { type primary; file "db.example.com.internal"; };
};
view "outside" {
match-clients { any; };
recursion no;
zone "example.com" { type primary; file "db.example.com.public"; };
}; Views are matched in order, so the specific one comes first. Keep recursion off for outsiders, for the reasons in recursive vs. authoritative servers.
Private zones in the cloud
Cloud providers commonly offer a private DNS zone attached to a virtual private cloud. Machines in that network get the private records; the rest of the world sees the public zone. Feature names and the rules for overlapping zones differ by provider, so check their documentation.
What happens to a query
Note an important consequence of step two. When the internal server considers itself authoritative for example.com, it will not ask the public servers about names it lacks. If the public zone has shop.example.com and the internal copy does not, inside users are told it does not exist.
Keeping two zones consistent
Make the rule explicit: every public record that internal users need must also exist inside. To keep that manageable:
- Keep both zones in version control, or generate both from one source.
- When you add a public record, add the internal one in the same change.
- Remember mail and verification records such as MX and TXT, which are easy to overlook.
- Periodically compare the two with a script that queries both servers.
Querying both is quick:
dig @10.0.0.53 files.example.com +short
dig @ns1.example.com files.example.com +short Use your own internal server and public name server addresses. On Windows, Resolve-DnsName files.example.com -Server 10.0.0.53 does the same.
An alternative that avoids duplication is to use a dedicated subdomain for internal names, such as corp.example.com, served only internally. Names no longer collide, and it is obvious which side a record belongs to. For purely private names, avoid inventing a top-level ending that could be assigned publicly someday. A subdomain of a domain you own is the safest choice, and home.arpa is reserved for home networks. The ending .local is used by multicast DNS and tends to cause trouble if used for ordinary zones.
Where it goes wrong
Roaming laptops. A device that visits the office and then leaves may hold a cached private address that is unreachable from home, until the TTL expires. Short TTLs on split records help.
VPNs. A VPN has to tell the device which DNS server to use for which names. If it does not, remote workers get public answers. Sending only company domains through the VPN's resolver is called split DNS in many clients, and relates to split tunneling.
Encrypted DNS in browsers. A browser configured to use an outside resolver over HTTPS bypasses your internal server. Managed networks usually control this setting through device policy.
A second DNS server that is public. If clients are given an internal server and a public one "as backup", they may use either at any moment, and results become random. List only servers that know the internal answers.
Certificates. Users reach the same name inside and out, so the internal server needs a certificate valid for that name. Certificates from public authorities also appear in public logs, which can reveal internal hostnames; see certificate transparency logs.
DNSSEC. If the public zone is signed and your internal copy is not, validating clients may reject the internal answers. Plan this before enabling validation.
A worked example for a small office
Say an office has a public website hosted elsewhere, a file server on its own network at 10.0.0.20 and a remote access address on its firewall at 203.0.113.20. Staff use the single name files.example.com wherever they are.
The public zone holds:
www 300 IN A 198.51.100.25
files 300 IN A 203.0.113.20
@ 3600 IN MX 10 mail.example.net. The internal zone holds:
www 300 IN A 198.51.100.25
files 300 IN A 10.0.0.20
printer 300 IN A 10.0.0.31
@ 3600 IN MX 10 mail.example.net. Only files differs. printer exists only inside. The website and mail records are copied unchanged, because without them office staff would be told those do not exist.
To roll this out, build the internal zone on the office DNS server, test it from one machine by querying that server directly, and only then change the DNS address that DHCP gives to everyone. Keep the TTLs short during the first few days so that a mistake is quick to correct.
Alternatives worth weighing
Fix hairpinning at the firewall. If your equipment can loop internal traffic back correctly, you keep a single set of DNS records. The cost is extra load on the firewall and a configuration that is less obvious to the next administrator.
Use different names. Publish files.example.com outside and files.corp.example.com inside. Nothing is ever ambiguous, but users have to know which to use, and bookmarks break when they move between networks.
Reach everything over a VPN or an identity-aware proxy. If internal services have no public records at all, there is only one answer to maintain. Remote users must connect through that channel first.
Edit hosts files. This works for a quick test on one machine and scales very badly. Entries are forgotten and cause confusion long after the reason has gone.
Do you need it?
Skip split-horizon DNS if hairpinning works on your firewall and you have nothing to hide, or if a separate internal subdomain covers your needs. Use it when internal and external users must use the same name and reach it by different paths.
It should never be your only security. Hiding a name does not protect the machine behind it. Anyone who knows or guesses the address can try it, so firewall rules and authentication still do the real work.
Write the design down as well. A short page that says which server holds which version, who may edit each and why the split exists will save the next person from "fixing" an internal record that was different on purpose.
Troubleshooting checklist
- Confirm which DNS server the affected client is actually using.
- Query the internal server directly and compare with what the client receives.
- Flush the client's cache and restart the browser.
- Check the VPN's DNS settings and the browser's secure DNS option.
- Look for a missing record in the internal copy of the zone.
- Check the hosts file for a forgotten override.