Sub topic 16
Split-Horizon DNS with Views
Prerequisites and the working model
Assume you can edit BIND configuration files, manage services with systemd, and test DNS with dig. Split-horizon DNS is a design where one DNS name returns different answers depending on the client’s network or source address. BIND implements this with views. A view is a separate set of zones and policies selected for a query.
For example, clients on the private network might resolve www.example.com to 192.0.2.20, while Internet clients receive the public address 198.51.100.20.
Configure two views
Define client networks with an ACL, then place a complete copy of the relevant zone in each view. BIND checks views in order, so put the most specific view first. The final view usually matches everyone else.
acl "internal-networks" {
127.0.0.1;
192.0.2.0/24;
};
view "internal" {
match-clients { internal-networks; };
recursion yes;
allow-query { internal-networks; };
zone "example.com" {
type primary;
file "/etc/bind/db.example.com.internal";
};
};
view "external" {
match-clients { any; };
recursion no;
allow-query { any; };
zone "example.com" {
type primary;
file "/etc/bind/db.example.com.external";
};
};The internal and external zone files need matching SOA records and serial numbers, but their address records can differ. Keep internal-only names out of the external file. For example, the internal file might contain:
$TTL 3600
@ IN SOA ns1.example.com. hostmaster.example.com. (
2026112801
7200
3600
1209600
3600 )
IN NS ns1.example.com.
www IN A 192.0.2.20
git IN A 192.0.2.30The external file could contain only www with its public address.
Common errors and trade-offs
Views are useful when one BIND server must answer both internal and external clients. They add operational cost because every changed record may need updating in multiple zone files. Automation or a shared source of truth helps prevent drift.
A common error is defining a zone in only one view. Clients matched to the other view then receive REFUSED or SERVFAIL, depending on the rest of the configuration. Another error is enabling recursion in the external view. Public recursive service can be abused for reflection attacks and cache poisoning attempts.
Test each view from a source address that matches it:
sudo named-checkconf
sudo named-checkzone example.com /etc/bind/db.example.com.internal
sudo named-checkzone example.com /etc/bind/db.example.com.external
sudo rndc reload
dig @192.0.2.10 www.example.com A
dig @192.0.2.10 git.example.com AExercise
Why must the external view set recursion no even when it serves public authoritative records?
Show answer
Authoritative answers still work with recursion disabled, while disabling recursion prevents arbitrary Internet clients from using the server as a recursive resolver.