This chapter provides a number of BIND configuration samples.
Running any DNS server that supports recursive queries for external users (an Open DNS) is a bad idea. While it may look like a friendly and neighbourly thing to do it carries with it a possible threat from DDoS attacks and an increased risk of cache poisoning. The various configurations have been modified to reflect this.
This chapter provides sample configurations and descriptions for each of the DNS types previously described. A BIND systems consists of the following parts:
Many BIND/DNS configurations are schizophrenic in nature - they may be 'masters' for some zones, 'slaves' for others, forward others and provide caching services for all comers. Where possible we cover alternate configurations or at least note the alternate configurations.
There are many in the DNS world who say that mixing DNS functionality in a single instance of BIND is a Very Bad Idea™ and leads to increased security risks. Such folks tend to get especially vocal about mixing ANY master or slave zones with caching (recursive) services. Such blanket advice overlooks pragmatic considerations. In a high volume DNS scenario it is both crazy and dangerous to run anything other than an authoritative only server (with no caching/recursive support). When small or modest volume DNS servers are used, and provided that the DNS is CLOSED, the modest increase in security threat is usually more than offset by operational benefits.
All the configuration files are deliberately kept simple - links are provided to the various sections that will describe more advanced parameters as appropriate. Comments are included in the files to describe functionality. The configuration used throughout is:
Everyone has their own ideas on a good naming convention and thus something that is supposed to be useful becomes contentious.
Here is a convention that is in daily use. Its sole merits are; it is a convention; it makes sense to its authors.
All zone files are placed in /var/named/ (for Windows users this would be %systemroot%\system32\drivers\etc). The base directory contains all the housekeeping zone files (e.g. localhost, reverse-mapping, root.servers etc.) with a subdirectory structure used as follows:
master files are named master.example.com (or master.example.net etc.) if its a sub-domain it will be master.sub-domain.example.com etc.
slave zone files are named slave.example.com (or slave.example.ca etc.) if its a sub-domain it will be slave.sub-domain.example.com etc.
The root server zone file is called root.servers (typically called named.ca or named.root in BIND distributions).
The reverse mapping file name uses the subnet number and .rev, that is, if the zone is '23.168.192.IN-ADDR.ARPA' the file is called 192.168.23.rev to save having to reverse the digits at 3AM in a blind panic.
The 'localhost' zone file is called master.localhost (typically called localhost.zone on BIND distributions). The reverse mapping file is called localhost.rev (typically called named.local in BIND distributions).
Note: For most Linux distributions you have a small overhead at the beginning to rename the supplied files but the author considers it worthwhile in the long run to avoid confusion.
Final point on this topic: Whatever your convention be rigorous in its application and don't get hung up on standard distribution file names, make them useful to you. The names were not handed down on tablets of stone.
The functionality of the master name server was previously described.
The BIND DNS configuration provides the following functionality:
The BIND 'named.conf' is as follows (click to look at any file):
// MASTER & CACHING NAME SERVER for EXAMPLE, INC. // maintained by: me myself alone // CHANGELOG: // 1. 9 july 2003 - did something // 2. 16 july 2003 - did something else // 3. 23 july 2003 - did something more // options { directory "/var/named"; // version statement - inhibited for security // (avoids hacking any known weaknesses) version "get lost"; // optional - disables all transfers // slaves allowed in zone clauses allow-transfer {"none";}; // Closed DNS - permits only local IPs to issue recursive queries // remove if an Open DNS required to support all users // or add additional ranges allow-recursion {192.168.3.0/24;}; }; // // log to /var/log/named/example.log all events from // info UP in severity (no debug) // defaults to use 3 files in rotation // BIND 8.x logging MUST COME FIRST in this file // BIND 9.x parses the whole file before using the log // failure messages up to this point are in (syslog) // typically /var/log/messages // logging{ channel example_log{ file "/var/log/named/example.log" versions 3 size 2m; severity info; print-severity yes; print-time yes; print-category yes; }; category default{ example_log; }; }; // required zone for recursive queries zone "." { type hint; file "root.servers"; }; zone "example.com" in{ type master; file "master/master.example.com"; // enable slaves only allow-transfer {192.168.23.1;192.168.23.2;}; }; // required local host domain zone "localhost" in{ type master; file "master.localhost"; allow-update{none;}; }; // localhost reverse map zone "0.0.127.in-addr.arpa" in{ type master; file "localhost.rev"; allow-update{none;}; }; // reverse map for class C 192.168.0.0 zone "0.168.192.IN-ADDR.ARPA" in{ type master; file "192.168.0.rev"; };
A Master server without the caching service is shown under Authoritative Only.
The functionality of the slave name server was previously described.
The BIND DNS configuration provides the following functionality:
Note: Since we are defining the slave the alternate sample file is used throughout this example configuration with all servers being internal to the domain.
The BIND 'named.conf' is as follows (click to look at any file):
// SLAVE & CACHING NAME SERVER for EXAMPLE, INC. // maintained by: me myself alone // CHANGELOG: // 1. 9 july 2003 - did something // 2. 16 july 2003 - did something else // 3. 23 july 2003 - did something more // options { directory "/var/named"; // version statement - inhibited for security // (avoids hacking any known weaknesses) version "not currently available"; // allows notifies only from master allow-notify {192.168.0.1}; // disables all zone transfer requests allow-transfer{"none"}; // Closed DNS - permits only local IPs to issue recursive queries // remove if an Open DNS required to support all users // or add additional ranges allow-recursion {192.168.3.0/24;}; }; // // log to /var/log//named/example.log all events // from info UP in severity (no debug) // defaults to use 3 files in rotation // BIND 8.x logging MUST COME FIRST in this file // BIND 9.x parses the whole file before using the log // failure messages up to this point are in (syslog) // typically /var/log/messages // logging{ channel example_log{ file "/var/log/named/example.log" versions 3 size 2m; severity info; print-severity yes; print-time yes; print-category yes; }; category default{ example_log; }; }; // required zone for recursive queries zone "." { type hint; file "root.servers"; }; // see notes below zone "example.com" in{ type slave; file "slave/slave.example.com"; masters {192.168.0.1;}; }; // required local host domain zone "localhost" in{ type master; file "pri.localhost"; allow-update{none;}; }; // localhost reverse map zone "0.0.127.in-addr.arpa" in{ type master; file "localhost.rev"; allow-update{none;}; }; // reverse map for class C 192.168.0.0 (see notes) zone "0.168.192.IN-ADDR.ARPA" IN { type slave; file "sec.192.168.0.rev"; masters {192.168.0.1;}; };
Notes:
The functionality of the Caching Only name server was previously described.
The BIND DNS configuration provides the following functionality:
The BIND 'named.conf' is as follows (click to look at any file):
// CACHING NAME SERVER for EXAMPLE, INC. // maintained by: me myself alone // CHANGELOG: // 1. 9 july 2003 - did something // 2. 16 july 2003 - did something else // 3. 23 july 2003 - did something more // options { directory "/var/named"; // version statement - inhibited for security // (avoids hacking any known weaknesses) version "not currently available"; // disables all zone transfer requests allow-transfer{"none";}; // Closed DNS - permits only local IPs to issue queries // remove if an Open DNS required to support all users // or add additional IP ranges // in this case either allow-query or allow-recursion can be used allow-query {192.168.3.0/24;}; }; // // log to /var/log/example.log all events // from info UP in severity (no debug) // defaults to use 3 files in rotation // BIND 8.x logging MUST COME FIRST in this file // BIND 9.x parses the whole file before using the log // failure messages up to this point are in (syslog) // typically /var/log/messages // logging{ channel example_log{ file "/var/log/named/example.log" versions 3 size 2m; severity info; print-severity yes; print-time yes; print-category yes; }; category default{ example_log; }; }; // required zone for recursive queries zone "." { type hint; file "root.servers"; }; // required local host domain zone "localhost" in{ type master; file "master.localhost"; allow-update{none;}; }; // localhost reverse map zone "0.0.127.in-addr.arpa" in{ type master; file "localhost.rev"; allow-update{none;}; };
Notes:
The functionality of the Forwarding name server was previously described.
The BIND DNS configuration provides the following functionality:
The BIND 'named.conf' is as follows (click to look at any file):
// FORWARDING & CACHING NAME SERVER for EXAMPLE, INC. // maintained by: me myself alone // CHANGELOG: // 1. 9 july 2003 - did something // 2. 16 july 2003 - did something else // 3. 23 july 2003 - did something more // options { directory "/var/named"; // version statement - inhibited for security // (avoids hacking any known weaknesses) version "not currently available"; forwarders {10.0.0.1; 10.0.0.2;}; forward only; // disables all zone transfer requests allow-transfer{"none";}; // Closed DNS - permits only local IPs to issue queries // remove if an Open DNS required to support all users // or add additional IP ranges // in this case either allow-query or allow-recursion can be used allow-query {192.168.3.0/24;}; }; // log to /var/log/example.log all events from // info UP in severity (no debug) // defaults to use 3 files in rotation // BIND 8.x logging MUST COME FIRST in this file // BIND 9.x parses the whole file before using the log // failure messages up to this point are in (syslog) // typically /var/log/messages logging{ channel example_log{ file "/var/log/named/example.log" versions 3; severity info; print-severity yes; print-time yes; print-category yes; }; category default{ example_log; }; }; // required local host domain zone "localhost" in{ type master; file "pri.localhost"; allow-update{none;}; }; // localhost reverse map zone "0.0.127.in-addr.arpa" in{ type master; file "localhost.rev"; allow-update{none;}; };
Notes:
The functionality of the Stealth name server was previously described. The following diagram illustrates the conceptual view of a Stealth (a.k.a. Split) DNS server system.
Figure 6.1 Split/Stealth Server configuration
The key issue in a 'Stealth' (a.k.a. Split) DNS system is that there is a clear line of demarcation between the 'Internal' Stealth server(s) and the 'External' or Public DNS servers(s). The primary difference in configuration is the 'Stealth' Servers will provide a comprehensive set of services to internal users to include caching and recursive queries and would be configured as a typical Master DNS, while the External server may provide limited services and would typically be configured as an Authoritative Only DNS server.
There are two critical points:
The zone file for the 'Stealth' server will contain both public and private hosts, whereas the 'Public' server's master zone file will contain only public hosts.
To preserve the 'Stealth' nature it is vital that the PUBLIC DNS configuration does not include options such as 'master', 'allow-notify','allow-transfer', etc. with references to the IP of the 'Stealth' server. If the Stealth servers IP where to appear in the Public DNS server and its file system were to be compromised the attacker could gain more knowledge about the organisation - they can penetrated the 'veil of privacy' by simply inspecting the 'named.conf file.
There are a number of articles which suggest that the view statement may be used to provide similar functionality using a single server. This does not address the problem of the DNS host system being compromised and by simple 'named.conf' file inspection additional data about the organisation being discovered. In a secure environment 'view' does not provide a 'Stealth DNS' solution if there is any possibility that a filesystem compromise can happen.
The functionality of the Authoritative name server was previously described. If security is not the primary requirement then the view statement may be used to provide 'Authoritative only' services to external users and more comprehensive services to internal users.
The configuration examples shown for authoritative only DNS servers all show the zones as being type master;. Thus if two (or more) DNS servers are being used the master zone files would have to be made available separately to all the servers by an out-of-band process (using, say, SFTP). In general this is the safest configuration. In situations where the zone files are highly dynamic, practical considerations may require that one or all of the zones be slaved from a single source. Zone transfer operations use TCP and are thus vulnerable to a new set of security and DoS threats. Avoid this configuration if possible, if not, as minimum secure the transfers with allow-transfer statements in the master zone clause and it may be worth considering use of TSIG to authenticate zone transfers.
An example configuration is shown below.
The BIND DNS configuration provides the following functionality:
The BIND 'named.conf' is as follows (click to look at any file):
// AUTHORITATIVE ONLY NAME SERVER for EXAMPLE, INC. // maintained by: me myself alone // CHANGELOG: // 1. 9 july 2003 - did something // 2. 16 july 2003 - did something else // 3. 23 july 2003 - did something more // options { directory "/var/named"; // version statement - inhibited for security // (avoids hacking any known weaknesses) version "not currently available"; // disable all recursion - authoritative only recursion no; // disables all zone transfer requests in this case // for performance not security reasons allow-transfer{none;}; }; // // log to /var/log/example.log all events // from info UP in severity (no debug) // defaults to use 3 files in rotation // BIND 8.x logging MUST COME FIRST in this file // BIND 9.x parses the whole file before using the log // failure messages up to this point are in (syslog) // typically /var/log/messages // logging{ channel example_log{ file "/var/log/named/example.log" versions 3 size 2m; severity info; print-severity yes; print-time yes; print-category yes; }; category default{ example_log; }; }; zone "example.com" in{ type master; file "master/master.example.com"; }; // reverse map for class C 192.168.0.0 zone "0.168.192.IN-ADDR.ARPA" in{ type master; file "192.168.0.rev"; }; // required local host domain zone "localhost" in{ type master; file "master.localhost"; allow-update{none;}; }; // localhost reverse map zone "0.0.127.in-addr.arpa" in{ type master; file "localhost.rev"; allow-update{none;}; };
Notes:
BIND provides three more parameters to control caching, max-cache-size and max-cache-ttl neither of which will have much effect on performance in the above case and allow-recursion which uses a list of hosts that are permitted to use recursion (all others are not) - a kind of poor man's 'view'.
The functionality of the Authoritative name server was previously described. If security is not the primary requirement then the view clause may be used to provide 'Authoritative only' services to external users and more comprehensive services to internal users.
The BIND DNS configuration provides the following functionality:
The BIND 'named.conf' is as follows (click to look at any file):
// VIEW BASED AUTHORITATIVE ONLY NAME SERVER for EXAMPLE, INC. // maintained by: me myself alone // CHANGELOG: // 1. 9 july 2003 - did something // 2. 16 july 2003 - did something else // 3. 23 july 2003 - did something more // // global options options { directory "/var/named"; // version statement - inhibited for security // (avoids hacking any known weaknesses) version "not currently available"; }; // // log to /var/log/example.log all events // from info UP in severity (no debug) // defaults to use 3 files in rotation // BIND 8.x logging MUST COME FIRST in this file // BIND 9.x parses the whole file before using the log // failure messages up to this point are in (syslog) // typically /var/log/messages // logging{ channel example_log{ file "/var/log/named/example.log" versions 3 size 2m; severity info; print-severity yes; print-time yes; print-category yes; }; category default{ example_log; }; }; // provide recursive queries and caching for internal users view "goodguys" { match-clients { 192.168.0.0/24; }; // our network recursion yes; // required zone for recursive queries zone "." { type hint; file "root.servers"; }; zone "example.com" { type master; // private zone file including local hosts file "view/master.example.com.internal"; }; // required local host domain zone "localhost" in{ type master; file "master.localhost"; allow-update{none;}; }; // localhost reverse map zone "0.0.127.in-addr.arpa" in{ type master; file "localhost.rev"; allow-update{none;}; }; }; // end view // external hosts view view "badguys" { match-clients {"any"; }; // all other hosts // recursion not supported recursion no; zone "example.com" { type master; // only public hosts file "view/master.example.com.external"; }; }; // end view
Notes:
Slave DNS Servers with View Clause When using Slave servers with view clauses it is important to recall that, even when NOTIFY is used, the Slave always initiates the zone tranfer operation using an INCOMING DNS operation (TCP on Port 53 normally). To ensure the correct domain is transferred the match-clients and/or match-destinations statements associated with the views must ensure that the requesting Slave server's IP is directed to the view containing the zone file that should be tranferred.
The functionality of the Split Horizon DNS was previously described. The view clause may be used to return different IP addresses to provide, say, geographically dispersed users with minimum access latency or even a level of load-balancing if you understand the service source-ip access profile (in this case the source-ip ranges in the example would be based on some analysis of incoming traffic not just geographic location).
The BIND DNS configuration provides the following functionality:
The BIND 'named.conf' is as follows (click to look at any file):
// VIEW BASED GEOGRAPHIC DNS SERVER for EXAMPLE, INC. // maintained by: me myself alone // CHANGELOG: // 1. 9 july 2009 - did something // 2. 16 july 2009 - did something else // 3. 23 july 2009 - did something more // // global options options { directory "/var/named"; // version statement - inhibited for security // (avoids hacking any known weaknesses) version "Name is Bind, James Bind"; // authors note: No idea who came up with the clever text but if you email // we'd be more than happy to credit it you - you deserve it allow-update{none;}; // defaulted if not present recursion no; // authoritative only }; // // log to /var/log/example.log all events // from info UP in severity (no debug) // defaults to use 3 files in rotation // BIND 9.x parses the whole file before using the log // failure messages up to this point are in (syslog) // typically /var/log/messages // logging{ channel example_log{ file "/var/log/named/example.log" versions 3 size 2m; severity info; print-severity yes; print-time yes; print-category yes; }; category default{ example_log; }; }; // map service to geographic origination view "gondor" { match-clients { 172.15/16; 172.14/16; }; // originate in gondor zone "example.com" { type master; // zone file will return www.example.com = 172.15.1.1 file "view/master.example.com.gondor"; }; }; // end view view "mordor" { match-clients { 172.16/16; }; // originate in mordor zone "example.com" { type master; // zone file will return www.example.com = 172.16.1.1 file "view/master.example.com.mordor"; }; }; // end view // default for everything else lies in a default view view "default" match-clients { "any"; }; // must be in the last block zone "example.com" { type master; // zone file will return www.example.com with default (worldwide) IP file "view/master.example.com.default"; }; };
Notes:
<groveling apology> Previous versions of this sample showed the default zones outside the view clauses which worked successfully in the original tests. At some point BIND, in its infinite wisdom, removed this feature. The rule, since at least BIND 9.5, is - if there is any view clause then all zones must be in view clauses.</groveling apology>
Slave DNS Servers with View Clause When using a Slave server with view clauses it is important to recall that, even when NOTIFY is used, the Slave always initiates the zone tranfer operation using an INCOMING DNS operation (TCP on Port 53 normally). To ensure the correct domain is transferred the match-clients and/or match-destinations statements associated with the views must ensure that the requesting Slave server's IP is directed to the view containing the zone file that should be tranferred.
Problems, comments, suggestions, corrections (including broken links) or something to add? Please take the time from a busy life to 'mail us' (at top of screen), the webmaster (below) or info-support at zytrax. You will have a warm inner glow for the rest of the day.
Contents
tech info
guides home
dns articles
intro
contents
1 objectives
big picture
2 concepts
3 reverse map
4 dns types
quickstart
5 install bind
6 samples
reference
7 named.conf
8 zone records
operations
9 howtos
10 tools
11 trouble
programming
12 bind api's
security
13 dns security
bits & bytes
15 messages
resources
notes & tips
registration FAQ
dns resources
dns rfcs
change log
This work is licensed under a
Creative Commons License.
If you are happy it's OK - but your browser is giving a less than optimal experience on our site. You could, at no charge, upgrade to a W3C STANDARDS COMPLIANT browser such as Firefox
Search
Share
Page
Resources
Systems
FreeBSD
NetBSD
OpenBSD
DragonFlyBSD
Linux.org
Debian Linux
Software
LibreOffice
OpenOffice
Mozilla
GitHub
GNU-Free SW Foundation
get-dns
Organizations
Open Source Initiative
Creative Commons
Misc.
Ibiblio - Library
Open Book Project
Open Directory
Wikipedia
Site
Copyright © 1994 - 2024 ZyTrax, Inc. All rights reserved. Legal and Privacy |
site by zytrax hosted by javapipe.com |
web-master at zytrax Page modified: January 11 2024. |