$INCLUDE Directive

$INCLUDE allows inclusion in-situ of an external file containing additional directives. It is typically used to assist in maintenance of larger DNS files e.g. you can distribute the maintenance of individual zone files to clients without exposing the global parameters or other client zones to inspection.

$INCLUDE is a standard directive defined in RFC 1035.

The RFC is silent on the topic of embedded $INCLUDEs in $INCLUDEd files - BIND 9 documentation is similarly silent. Assume they are not permitted.

RFC 1035 defines the format as:

$INCLUDE <filename> [domain-name]
The filename may be relative (to the location of the zone files) or absolute. The optional domain-name may be used to set an $explicit ORIGIN for the included file.

An included file can also contain one or more $ORIGIN directives. The scope of the $ORIGIN directives in included files is limited to the included file. $ORIGIN will revert to its value before the $INCLUDE directive.

Examples - no $ORIGIN in included file:

$ORIGIN uk.example.com.
@          IN      NS     ns2.example.com. 
; ns2.example.com services uk.example.com

$INCLUDE /var/named/uk.example.com ; absolute path
...
ftp        IN      A   192.168.35.16
; expands to ftp.uk.example.com 

The next fragments shows the contents of the included file and how they expand.

; file statements in /var/named/uk.example.com
www       IN       A  192.168.23.15 
; expands to www.uk.example.com
...
; end of included file

Example with ORIGIN directive:

$ORIGIN uk.example.com.
@          IN      NS     ns2.example.com. 
; ns2.example.com services uk.example.com

$INCLUDE french.subdomain ; relative path file
; ORIGIN reverts to value before the $INCLUDE directive
ftp        IN      A   192.168.35.16
; expands to ftp.uk.example.com 

Included file contents containing $ORIGIN.

$ORIGIN fr.example.com.
www       IN       A  192.168.23.15 
; expands to www.fr.example.com
...
; end of included file

Example of explicit ORIGIN with $INCLUDE:

$ORIGIN uk.example.com.
@          IN      NS     ns2.example.com. 
; ns2.example.com services uk.example.com

$INCLUDE french.subdomain fr.example.com ; relative path
; ORIGIN reverts to value before the $INCLUDE directive
ftp        IN      A   192.168.35.16
; expands to ftp.uk.example.com 

Included file uses $INCLUDE explicit $ORIGIN.

; no $ORIGIN directive
www       IN       A  192.168.23.15 
; expands to www.fr.example.com
...
; end of included file

Pro DNS and BIND by Ron Aitchison

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 dns 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 rfc's
change log