Running a Private BIND DNS Server

You’re tired of dinking around with /etc/hosts; you’re ready to implement some grown-up name resolution on your LAN by installing a BIND DNS server. You only want this server to be available to your local users, providing both name-resolution and caching services. It will not provide any public services.


Set up a caching name server. Then add zone blocks to named.confto define the new zones for your LAN hosts, and construct the zone files.

Table 1 lists the five hosts on






DNS, mail





Web server







Add these zone blocks to named.conf:

zone "" IN {

type master;

file "";


zone "" {

type master;

file "revp.10.11.12";


Here is the actual zone file for


// dns zone for for




; any time you make a change to the domain, bump the

; "serial" setting below. the format is easy:

; YYYYMMDDI, with the I being an iterator in case you

; make more than one change during any one day

@ IN SOA parsley hostmaster (

200405191 ; serial

8H ; refresh

4H ; retry

4W ; expire

1D ) ; minimum

; serves this domain as both the

; name server (NS) and mail exchange (MX)

NS parsley

MX 10 parsley

; define domain functions with CNAMEs

ftp CNAME sage

www CNAME rosemary

; just in case someone asks for

localhost A

; our hostnames, in alphabetical order

rosemary A

sage A

parsley A

thyme A

cilantro A

And finally, here are the reverse lookups for the domain in the revp.10.11.12 file:

; revp.10.11.12

; reverse pointers for subnet




@ IN SOA (

200405190 ; serial

28800 ; refresh (8 hours)

14400 ; retry (4 hours)

2419200 ; expire (4 weeks)

86400 ; minimum (1 day)


; define the authoritative name server


; our hosts, in numeric order






Save your changes and restart BIND:

# /etc/init.d/named restart

And there you are—a shiny new fully functioning DNS server for your LAN.


There’s a whole lot happening in these three files. First of all, putting each zone into its own file is good organization. You may dump everything into a single zone file if you like, but you’ll find that it’s difficult to maintain.

In named.conf, the entries for tell BIND that it is the authoritative server for, and where to find the zone files.

The $origin directive is a nice timesaver. It lets you write:


www CNAME rosemary

instead of:    CNAME

$TTL 1D sets a default time-to-live value. Values can be in this format:


For week


For day


For hour


For minute


For second

Individual entries may have their own TTL values:

rosemary      72h    A

The TTL tells visitors how often to refresh their own caches. If your site is fairly static, set this to a higher value. If you’re making frequent changes, use a lower value. The lower the TTL, the more hits there will be on your server.

@ IN SOA parsley hostmaster means:



This holds the same value as $ORIGIN.


This defines the address class; IN = Internet.


Start of Authority; the beginning of a zone file. Only A records can be used as the MNAME—don’t use CNAMEs.

The SOA has 10 fields. These are the primary domain name, zone class, and SOA, plus the following:


The master name server for the zone.


The email address of the domain admin.

Serial number

BIND converts zone files into a binary file format. When you make changes to the zone file, you must also change the serial number, or BIND will not recognize the changes.


This tells your slave, or secondary servers how often to check for updates.


If the master DNS server for the zone fails to answer a slave server’s request for an update, this tells the secondary server how often it should resend the request.


If the master DNS server fails for a longer period of time, this tells the the secondary server how to continue to use its existing data. After the expire time has passed, the data is considered stale and will not be used, at which time the domain will no longer resolve. Hopefully your master server will be back online before this happens.

Minimum, or Negative-caching TTL

Negative answers (such as when a requested record does not exist) should also be cached on nonauthoritative servers. Setting this value prevents your server from getting hammered by a bunch of repeated requests in a short time. A common use for this is when you are migrating to a new name server at a different IP address; setting a short value on the old server a few days before you take it offline assures that your change will propagate quickly.

The next section contains resource records (RRs).

NS parsley and MX 10 parsley define your name server and mail server. If you have more than one mail server for the domain, the number sets the priority. Lower numbers are higher priority. Because $ORIGIN defines the domain name for the whole record, these expand to and Make note of the trailing dot—this is very important! That defines the qualified domain name. If you leave it off, BIND will think it needs to append the domain name, so you’ll have silliness like

CNAME (canonical name) is an alias to an A record. Thus, a single A record can have several aliases. You can use a CNAME to add subdomains for virtual web or mail hosting—for example, or

Instead of using CNAMES, you may assign subdomains their own A records. This means one less hit on your server per CNAME request, but it also means more work when you need to make changes. Endless debates rage over the use of CNAMEs; use what suits you.

"Canonical" is one of those weirdo geek words that defies a precise, logical definition. In this context, "canonical name" means "an alias assigned to the true (canonical) name of the server."

And finally, we come to the A (alias) records. An A record is the primary address for each of your hosts, the direct match of hostname to IP address.

Reverse pointers (RPTs) are technically not required, but in the real world so many servers require them that you had better use them.

If things are not working right, chances are it’s a syntax error or a typo—mind your dots and commas especially. There are two syntax checkers for BIND to help you.

The other common error is not starting from A records. Every host must first have an A record. Then you can assign name servers, mail servers, and CNAMEs.