The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]
sample zone files 26 July 1998
Need more help on this topic? Click here
This article has no comments
Show me similar articles
see also Getting local names to resolve (DNS).
About these examples
Please note that all names and numbers in these examples have been changed for security reasons.  These are examples and are not exact copies of the files used on our subnet.

It is important to note that FreeBSD 2.2.* uses a different version of named than FreeBSD 3.*.  In fact, the configuration file is a different name.  named.boot is for FreeBSD 2.2.* (BIND 4) and named.conf is for FreeBSD 3.*.

The zone files
The following files collectively define the zones of our subnet.

/etc/resolv.conf
/etc/namedb/named.boot
/etc/namedb/named.conf
/etc/namedb/named.dvl
/etc/namedb/named.dvl.rev
/etc/namedb/named.localhost
/etc/namedb/named.localhost.rev

named.boot should already exist on your system.  The other files will be created as needed.  I suggest you substitute your own domain name for the dvl portion of the file names.  The named.localhost and named.locahost.rev files can be copied to your system unchanged from this example.

The above files are referred to as zone files and I've provided copies of mine below.

This file tells DNS how to resolve names.  Or rather, it tells it where to find the answers.  For my system, I have the following entries.  Note that
domain		www.example.org
nameserver	127.0.0.1		# the freebsd box
nameserver	12.34.56.78		# change this to your ISPs name server
Use this example if you are using BIND 4 (FreeBSD 2.2.*), otherwise, use /etc/namedb/named.conf.

This file is referred to by an entry in /etc/rc.conf.  See the Starting the DNS Server section of the PPP - Pedantic PPP Primer for details.  In effect, the following entries tell DNS where to find more information.

You should subtitute your own domain for www.example.org but remember to retain the periods where they occur.  They are very important.

cache   .       		named.root
primary www.example.org.        named.dvl
primary 0.0.10.IN-ADDR.ARPA  	named.dvl.rev
primary localhost               named.localhost
primary 0.0.127.IN-ADDR.ARPA    named.localhost.rev

For details on what the above lines mean, please refer to your crab book.

The following line should point to your ISP's name server.  Please don't use the IP address supplied below.

forwarders 12.34.56.78

I found that the following line was not necessary, so I commented it out.

;options forward-only
Use this example if you are using BIND 8 (FreeBSD 3.*), otherwise, use named.boot.   I suggest you use the default file and then add to it using the following as an example.
zone "0.0.127.IN-ADDR.ARPA" {
        type master;
        file "localhost.rev";
};
zone "www.example.org" {
        type master;
        file "named.www.example.org";
};
zone "0.0.10.in-addr.arpa" {
        type master;
        file "www.example.org.rev";
};

The file /etc/namedb/make-localhost will create a localhost file for you.   Try typing:

cd /etc/namedb/
sh make-localhost
This file defines the FreeBSD box as the name server for this domain.  It also provides the IP addresses for each box within this subnet.
@	IN SOA  www.example.org.	root.freebsd.www.example.org.        (
						961230	; Serial
						3600	; Refresh
						300	; Retry
						3600000	; Expire
						3600  )	; Minimum
	IN NS	freebsd.www.example.org.

;
; Define the rest of the subnet
;
freebsd.www.example.org.	IN A	10.0.0.10	; The FreeBSD box
nt2.www.example.org.	IN A	10.0.0.2	; The 486
nt1.www.example.org.	IN A	10.0.0.1	; The Pentium
This file defines which host belongs to what IP address.  You will notice that the section in named.boot which refers to this file contains the phrase "0.0.10.IN-ADDR.ARPA".   If you reverse the numbers at the front of that phrase and then append the number you find below, you get the address of the host in question.  For example, 10.0.0.1 is the IP address assigned to NT1. 
@	IN SOA  www.example.org.	root.freebsd.www.example.org.        (
						961230	; Serial
						3600	; Refresh
						300	; Retry
						3600000	; Expire
						3600  )	; Minimum

		IN NS	freebsd.www.example.org.
10              IN PTR  freebsd.www.example.org.
1		IN PTR	nt1.www.example.org.
2		IN PTR	nt2.www.example.org.
This file defines the localhost entry, 127.0.0.1.  This is a well-defined loopback for all hosts.
@	IN SOA  www.example.org.	root.freebsd.www.example.org.        (
						961230	; Serial
						3600	; Refresh
						300	; Retry
						3600000	; Expire
						3600  )	; Minimum

		IN NS	freebsd.www.example.org.
localhost.      IN A    127.0.0.1

As with the named.dvl.rev file, the section in named.boot which refers to this file contains the phrase "0.0.127.IN-ADDR.ARPA".   When reversed and prefixed to the entry below, we find that 127.0.0.1 is localhost.
@	IN SOA  www.example.org.	root.freebsd.www.example.org.        (
						961230	; Serial
						3600	; Refresh
						300	; Retry
						3600000	; Expire
						3600  )	; Minimum

		IN NS	freebsd.www.example.org.
1		IN PTR	localhost.

Need more help on this topic? Click here
This article has no comments
Show me similar articles