Sub topic 3
Using BIND as a recursive resolver or forwarder
This chapter assumes a working BIND install, the zone from the earlier chapters, and comfort with named.conf, systemd, and dig. A recursive resolver walks the DNS tree on behalf of a client. A forwarder passes queries to another resolver instead.
Recursive resolver and forwarder settings
Limit recursion to your own networks. An open recursive server can be abused for traffic amplification.
options {
recursion yes;
allow-recursion { 127.0.0.1; 192.0.2.0/24; };
dnssec-validation auto;
forwarders { 192.0.2.53; };
forward first;
};forward first asks the forwarder and falls back to full recursion if it fails. forward only removes the fallback.
Validating DNSSEC on your resolver
dnssec-validation auto; checks signatures against the built-in root trust anchor. Test it with a signed name:
dig @127.0.0.1 example.org A +dnssecLook for the ad (authenticated data) flag in the header line.
Zone transfers with TSIG
TSIG is a shared-key signature on zone transfers. Generate a key on the primary:
tsig-keygen transfer-keyOn the secondary, add the key and the zone:
key "transfer-key" { algorithm hmac-sha256; secret "BASE64SECRET=="; };
server 192.0.2.10 { keys { transfer-key; }; };
zone "example.com" {
type secondary;
primaries { 192.0.2.10; };
file "/var/cache/bind/db.example.com";
};On the primary, define the same key and set allow-transfer { key "transfer-key"; }; in the zone.
Reverse zones and PTR records
For 192.0.2.0/24, the reverse zone is 2.0.192.in-addr.arpa. Declare it as a primary zone and give it an SOA and NS records, as in a forward zone. A PTR record maps the last octet to a name:
20 IN PTR www.example.com.Split-horizon DNS with views
Views let internal and external clients receive different answers. The first matching view wins, and once any view exists, every zone must sit inside a view.
view "internal" {
match-clients { trusted; };
recursion yes;
zone "example.com" { type primary; file "/etc/bind/db.example.com.internal"; };
};
view "external" {
match-clients { any; };
recursion no;
zone "example.com" { type primary; file "/etc/bind/db.example.com"; };
};Hardening the server
Hide the version string and restrict queries and transfers:
options {
version "none";
allow-query { any; };
allow-transfer { none; };
};Logging and troubleshooting
Check the configuration before every reload, then read the logs when something fails:
sudo named-checkconf
sudo rndc reload
sudo rndc status
sudo journalctl -u named --since "10 min ago"
sudo unbound-control statusExercise
Which option limits recursive answers to trusted clients, and what value does it take in your ACL example?
Show answer
allow-recursion, set to the trusted networks, such as { trusted; } or { 127.0.0.1; 192.0.2.0/24; }.