Internal clients need to reach app.example.com on a private RFC1918 address; external clients need the public IP. Both live in the same zone name, so a single global view of the zone will not work. This article walks through BIND9 view blocks: the match-clients clause, the ordering rule, and how to keep the two horizons from leaking into each other. The deliverable is a single named instance that answers correctly based on who asked.
How to verify
Before changing config, confirm what the box answers today from each network position. The fastest path is to query from a known-internal address and a known-external address and compare:
dig @203.0.113.10 -b 10.0.5.50 app.example.com A +short
dig @203.0.113.10 -b 198.51.100.5 app.example.com A +short
sudo rndc dumpdb -all && head -50 /var/cache/bind/named_dump.db
journalctl -u named -n 30 --no-pager | grep -E 'view|match'
The -b flag sets the source address for the query. If both queries return the same record, the box has no view configured (or both clients fall into the same view). If they differ, the views are working.
What’s happening
A BIND view block is a virtualized zone container. Each view has its own match-clients ACL — the clients allowed to see this view — and its own set of zone definitions. When a query arrives, BIND evaluates views in the order they appear in the config and serves the first one whose match-clients ACL matches the source address. There is no fallback: if no view matches, BIND returns REFUSED.
This means three things matter operationally:
- View ordering is policy. The first match wins. Always put the most specific view first.
- Every zone you want a client to see must be defined inside their view. If
internalhasexample.combutexternaldoes not, external clients get REFUSED for that name even though it exists. - The cache is per-view. A recursive view caches answers it resolved on behalf of its clients; another view does not share that cache. Memory and resolver query traffic both scale with view count.
Split-horizon is most often two views (internal, external), but three is common (internal, dmz, external) and four happens in larger deployments. Beyond that, complexity grows fast — usually a sign that the problem belongs in a different layer (anycast, response policy zones, or a service mesh).
The procedure
-
Define ACLs at the top of
named.conf.local. ACLs cannot be referenced before they are defined:acl "internal-nets" { 10.0.0.0/8; 192.168.0.0/16; localhost; localnets; }; acl "external-nets" { any; // anything that did not match internal-nets falls here }; -
Wrap zones in view blocks. Note that you can include the same zone in multiple views with different file paths:
view "internal" { match-clients { internal-nets; }; recursion yes; allow-recursion { internal-nets; }; zone "example.com" { type primary; file "/etc/bind/zones/internal/db.example.com"; }; include "/etc/bind/named.conf.default-zones"; }; view "external" { match-clients { external-nets; }; recursion no; zone "example.com" { type primary; file "/etc/bind/zones/external/db.example.com"; }; }; -
Build two zone files. They share name and SOA structure but diverge on the A/AAAA records:
/etc/bind/zones/internal/db.example.com:$TTL 300 @ IN SOA ns1.example.com. hostmaster.example.com. ( 2026060201 ; serial 3600 600 1209600 300 ) IN NS ns1.example.com. app IN A 10.0.5.50 db IN A 10.0.5.51/etc/bind/zones/external/db.example.com:$TTL 300 @ IN SOA ns1.example.com. hostmaster.example.com. ( 2026060201 ; serial 3600 600 1209600 300 ) IN NS ns1.example.com. app IN A 203.0.113.50Keep the SOA serial values aligned across views — diverging them causes bizarre transfer behaviour when one view is also a primary for downstream secondaries.
-
Validate and reload. Each view must validate cleanly:
sudo named-checkconf -z sudo systemctl reload named -
Test from both sides. Use a host on each network or
-bif you can spoof source:dig @ns1.example.com app.example.com A +short # from internal host dig @ns1.example.com app.example.com A +short # from external host -
Audit which view a query landed in. Enable per-query logging on a high-cardinality system only briefly — it is verbose:
logging { channel query_log { file "/var/log/named/query.log" versions 5 size 50m; severity info; print-time yes; }; category queries { query_log; }; };
Common pitfalls
- Forgetting
include "/etc/bind/named.conf.default-zones"inside views. The default zones (root hints, localhost, in-addr.arpa) are global by default, but once you switch to views they must be referenced inside each view that needs them. Otherwise recursion breaks because the resolver has no root hints. - Wildcard
match-clientsswallowing everything. An early view withmatch-clients { any; }matches every client and the later views never get hit. Order matters. - Stale cached records when a client moves between views. A client that resolved through the internal view, then moves to a coffee shop (now external), may still hold the internal A record in its OS cache. TTLs in split-horizon zones should be short (60-300s).
- TSIG signed transfer crossing views. A secondary pulling a zone has to land in the correct view. Use TSIG keys per-view if you have transfer relationships per-view, and watch for “view ‘external’ has no zone ‘example.com’” errors when the wrong key is presented.
- DNSSEC and views. Signing both views of the same zone with the same keys works, but the inception/expiration timestamps may drift. Either share one signing pipeline that writes both files, or sign each separately and accept the slightly different RRSIG timestamps.
In the engagements we run, split-horizon usually shows up because someone exposed an internal service on a public name and wants to keep the public answer pointing at an edge proxy. The view machinery is reliable; the operational pain is in keeping the two zone files from drifting. We codify both views in the same change pipeline, alert on serial mismatch, and document the horizon boundary so the team can debug it at 3am. See our managed operations service for the broader operating model.