However it does simplify the common tedious error-prone parts of maintaining a DNS installation, such as:
The program bin/hosts2db.pl is provided to convert from /etc/hosts format to the host database format.
A simple method for creating cloned domains is provided. This is useful for sites which need to support large number of virtual hosts and virtual domains. See Clone Domains.
A few variables in the Makefile have been renamed in line with the change of the database directory structure. You no longer need to set OURSUBDOMAINS
Another welcome change is the removal of the restriction which meant that a subnet could not be split across domains. Many thanks to Dave Roberts for the changes to fix this.
In accordance with correct DNS practice, underscores are no longer allowed in hostnames by default. The section Installing DNStool tells you how to change this if you really must support underscores.
The major change from version 2.0 to version 2.1 is the ability to
handle multiple top-level domains. In version 2.0, the host database
files were stored in the db directory. In version 2.1 and
later, separate directories are created in the db
directory, one per entry in the variable OURFQDNS in the
Makefile. For example, if we dealt with the DNS for
gormand.com.au, frog.pond and swamp.net, we would create a minimu of
three files, db/gormand.com.au/src.gormand,
db/frog.pond/src.frog and
db/swamp.net/src.swamp. Each of these files is in the
format described in the section describing the host database.
The host database does not contain information about the domain (such as its name servers) or information that is not tied to a host in the domain. It only describes individual hosts in the domain.
The current version allows global aliases to be created for hosts - this alias will be generated in all domains managed by the DNStool. This can be useful to deal with software which does not properly handle domain structures, such as some license packages, and older versions of Sun's rpc.lockd.
{ and ends with a closing brace }. Within
each host record are a number of clauses, each of which is of the
form
Note: The syntax has been tightened slightly from that allowed in the
previous version of this tool. This is due to the simplicity of the
current PERL parser when compared with the previous Lex/YACC parser.
keyword = value
; or #
and continue to the end of the line. Blank lines and lines containing
only comments are ignored. For more details, see the example
Value fields may contain comments
keyword = value clauses.
keyword = value clauses may span multiple
lines, but the first part of the value must appear on the same line as
the keyword.
For more details, see the example
Multiline value fields
" and may not extend across lines
dns2host
generate lines which start with the words NS, MX and Nickname. These
lines are not inside the braces which delimit host entries and do not
have the mandatory = separating the key and value. These
lines refer to domain (rather than host) features and are irrelevant
in the host database. These were previously ignored, but now cause
syntax errors. They will need to be removed manually if the
dns2host generation programs are used.
{
host = banana
ip = 192.168.42.20
}
while an enlarged host record looks like
{
host = banana
ip = 192.168.42.20
192.168.15.20
192.168.27.20
aliases = mailhost loghost
location = "Level 4 machine room"
owner = "Gormand Pty Ltd"
hostid = 0xaabbccddeeff
ether = AA:BB:CC:DD:EE:FF
server = "banana"
mx = 5 banana
os = "Linux"
hardware = "AMD K6"
comment = "random bit of additional text"
}
The equals sign between a keyword and its value is
mandatory and it must be surrounded by whitespace.
The host and ip clauses are mandatory and must appear
in that order. The rest of the clauses are optional
and can appear in any order. So
and
{
host = banana
ip = 192.168.42.20
alias = www proxy mail
ether = AA:BB:CC:DD:EE:FF
}
are both legal and equivalent.
{
host = banana
ip = 192.168.42.20
ether = AA:BB:CC:DD:EE:FF
alias = www proxy mail
}
ips and
aliases). List values are separated by spaces. For
example
alias = mailhost loghost
The syntax of the mail exchanger value is that of the DNS Resource Record, separated by one or more spaces. For example
mx = 10 mail 50 mail2
The syntax of the ether value is the conventional representation of ethernet addresses: six groups of one or two hex digits, separated by colons. The letters A-F may be in upper or lower case. For example, all of the following are legal and equivalent
ether = 1b:2c:3d:04:0c:05
ether = 1b:2C:3D:44:0C:05
ether = 1b:2c:3d:44:c:5
There is no requirement to have both a hardware and os clause: you can use either, both or neither. If only one is included, the other will be given the static value blank. This avoids a bug in some early versions of named, which could not handle empty fields in the HINFO resource records.
} of a host record or another keyword =
value clause. The first part of the value field
must appear on the same line as the keyword.
For example
{
host = ahost
ip = 192.168.8.33
192.168.10.33
}
is equivalent to
{
host = ahost
ip = 192.168.8.33 192.168.10.33
}
but
{
host = ahost
ip =
192.168.8.33
192.168.10.33
}
is illegal and will produce a syntax error from the parser.
{
host = ahost
ip = 192.168.8.33
# 192.168.10.33
192.168.12.33
}
is equivalent to
{
host = ahost
ip = 192.168.8.33 192.168.12.133
}
host = hostname clause, is a handle referring to all
possible IP addresses, and interface-specific hostnames are generated
for each of the IP addresses.For example, given a host padwft1 which has three IP addresses
{
host = router-1
ip = 192.168.10.1 192.168.20.1 192.168.30.1
}
DNStool will automatically produce DNS information for four hosts
will result in a DNS name rotary1 with two IP addresses,
192.168.110,199 and 192.168.110.198. Once the rotary is defined on the
two Annex boxes at these addresses, it is possible to type telnet
rotary1, and telnet will try all available ports on one terminal
server, followed by the ports on the other terminal server. The above
example generates three hostnames
{
host = rotary1
ip = 192.168.110.199 192.168.110.198
hw = "MicroAnnex Annex XL"
comment = "Annex Rotary"
}
{
host = rarp
ip = 192.168.220.1 .. 192.168.220.4
}
In this situation, DNStool automatically generates DNS information for 4 hosts, named by appending the last two IP components to the host name
rarp is
not generated. IP ranges may contain tens, or
hundreds of hosts, whereas DNS resolver queries may only return less
than 16 IP addresses per host. These range hosts are only useful in
case such as bootp and rarp addresses, where the actual name is not
important, just the existance of a name to ip address mapping.
IP ranges cannot span subnets, i.e. only the last field of the IP
address is allowed to vary in the range. A range specification such
as
ip = 192.168.220.1 .. 192.168.221.12
is illegal. More complex specifications can be constructed using sets of IP addresses, IP ranges, or both. Checks are performed to ensure that a range does not overlap with other IP addresses in the host record or with other IP addresses in the domain. There are two consequences of multiple IP address specifications
{
host = foo
ip = 192.168.10.1
192.168.11.1
}
{
host = foo-le1
ip = 192.168.11.1
}
as the ip address 192.168.11.1 appears in two host
records. The recommended way to represent this information is to make
use of the mechanism provided for multi-homed hosts. That is, use
{
host = foo
ip = 192.168.10.1
192.168.11.1
}
and make use of the generated names foo-10 and
foo-11 instead of foo-le1.
db/PROTO/src.PROTO and
db/PROTO/special.PROTO which list
the standard configuration for the domains. Examples are provided
in the db/samples directory.
db/PROTO
directory before the domains are generated, and then treated as
for any other domain.
special.${domain} files in the db
directory. These features are information such as site-based MX
records, delegated sub-domains and delegated sub-networks. These files
are copied verbatim into the appropriate output file,
and are inserted after the first blank line in the h2n generated
output file, i.e. directly after the SOA record.As these files are copied directly into the output files, it is vital that they are checked for correctness as they will not be checked by the tool. Most importantly, ensure that all lines which should be terminated with full-stops are, as this is the most common error in editing DNS files. Refer to DNS and BIND for full details.
Special files can now be added to any domain file. If a special file exists, it is automatically included just after the SOA of the generated zone file. The files are optional. Some common special files are:
db.${OURNET} (or possibly
db.iroot if you are using an internal root).
The file is named special.${topdomain}, i.e. the
first part of ${OURFQDN}.
For example, for gormand.com.au, this file is
db/special.gormand and is provided as an example in
db/samples/special.gormand. It provides for delegation of
the research.gormand.com.au sub-domain.
in-addr.arpa. domain for the
network numbers from the internal root. An example is provided in
db/samples/special.iroot
/usr/bin/perl. Note: The DNStool package is based
on PERL5, and PERL4 will not work
/usr/local/domain/src
gormand.com.au frog.pond swamp.net.
OURFQDNS. This would
usually be a Class B or Class C IP network address, without
the trailing zeroes. For example, 192.168. The
format of this line is described in the Makefile.
-i if you want to generate an
internal root for your network. This should only be used if
you are not connected to the Internet or any other external
network. Many corporations run internal roots, and you should
check whether a corporate internal root exists before you
create your own. Nameservers running internal roots
must not be directly connnected to the
Internet.
make
release target.
-
- OLDBASEDIR
-
This setting specifies the location of the previous DNStool
installation. You can then run
make compare to
see if the output has changed.
db/options.generic file, describing the
h2n options for your domain. See
db/samples/options.generic for an example, and see Appendix A: h2n options
files for full details.
db/src.domain file for the
top-level domain. For example, if the OURFQDN is
gormand.com.au, there needs to be a
db/gormand.com.au/src.gormand file.
special.domain files for the
top-level domain and internal root domain, if required. See Special Files for full details.
db/src.domain files for each domain
listed in OURSUBDOMAINS listed above.
The following subdirectories exist under the base directory
h2, dnsparse. It also includes other tools
for processing the host databases, such ipsfree for
finding free IP addresses in a domain and ipsused for
displaying the IP addresses used in a domain.
src.domain file.
gordonr@wheel[228] make
/usr/local/src/dns/test/dns.lock exists - DNS files are being generated by:
gordonr pts/29 Nov 27 09:07
*** Error code 1
make: Fatal error: Command failed for target `CheckLock'
To remove the lock, use the make CleanLock target of the
Makefile
hostdb/src.ced. Add an alias to one of the host
records.
db.ced and spcl.ced files in the
data directory to ensure that the alias has been added. The
db.ced and spcl.ced files are the DNS
configuration files describing the Ceduna hosts and aliases,
respectively.
err.ced file in the data
directory.
OURSUBDOMAINS
line in the master Makefile
src.dar file in the db directory, and add
host information for the Darwin domain to it
Within the two classes, there are a number of types of nameserver
make
release target informs all of the secondary nameservers when
changes are made to the host database, asking them to update their
databases as soon as they are able.
foo.gormand.com.au
as another secondary nameserver for your domains.
-s
nameserver statement to the db/options.generic file,
i.e. -s gormand.com.au. This is not required for
private nameservers.
For details, see Multi-homed hosts
It is also possible to use the make veryclean target to clean both the data and install subdirectories, although this is not normally required.
db/special.topdomain file to change the
nameservers. Remember, this file is included directly into a DNS
output file, and must be syntactically correct.
db/options.generic file. Change this file and then
autoconfigure.
srcgen.perl, which reads the installed
DNS files and translates them into the simpler format of the host
database. This program, and an example Makefile, live in the
hostdb subdirectory. These are examples, and will need
massaging for your particular DNS setup.
There is also a program in bin/host2db.pl which will convert /etc/hosts files to the host database format. Having performed the "reverse-engineering" once to initialise the database with the existing information, the host database will be manually maintained (as it will grow to contain a superset of the DNS data and will be used for additional purposes).
The program and its subsidiary files are in the dns2host
subdirectory, and the host database lives in the db
subdirectory. The host database is isolated from other strictly
generated data files. The hosts database consists of a group of
structured ascii files (one per domain), called
src.domain. For example, src.bwy is
the section for the bwy domain.
dnsparse, reads the host database,
checks its syntax and translates it to an intermediate form. If any
syntax errors are found in the file for a certain domain, dnsparse
will not produce output files for this domain. Errors are written to a
file in the data directory of the form
err.domain as well as displayed on the
screen.Limited semantic checking is done - semantic checks show that the file is `sensible' as well as syntactically correct. An error is produced for duplicate hostname or IP addresses within one domain (but not cross-domain). A warning message is produced for multiple occurrences of an ethernet address, but this does not affect dnsparse's output. Other checks - nonsensical mail exchanger info and so on - are not currently made.
Produce the /etc/hosts intermediate format
The host database is translated by dnsparse into a format
accepted by the DNS configuration file builder,
h2n. This format is that of the /etc/hosts file, with some subsidiary
files (known as comment and spcl files).
The output files are written to the data subdirectory (where all strictly generated files are placed). They are called
hosts.domain
The comment field starts with a #, immediately followed by a
number. This number is used as a key in the
resources.domain file. If the comment field
contains the string [no smtp], h2n will not
generate a default MX record for this host.
The default MX record is an MX record of weight 10, directed at this
host. This default MX record is suppressed for all hosts generated
by dnsparse. Extra MX records to override the -m
weight:host options to h2n should be entered using
the mx = weight host clause in the host database.
resources.domain
would generate HINFO and MX records as above for the host
number 10 in the
10: IN HINFO "SUN" "UNIX"
10: IN MX 10 mail.gormand.com.au
hosts.domain file.
spcl.domain
would generate the CNAME record for the host me. Note
that the
me IN CNAME myself.gormand.com.au
spcl.domain files are included
in the final output using $INCLUDE
spcl.domain directives to BIND.
globals.domain
spcl.domain files before
calling h2n.
nets.domain
-n a.b.c.d,
ready to be passed into h2n.
ethers.domain
ethers.domain file. This file is not used by
h2n but can be used to generate the ethers NIS
maps.
dbg.domain
err.domain
dbg.domain and err.domain are maintained in the event
of syntactical or semantic errors and the parser exits with an error
status, causing the make to fail.
h2n assumes that its input files are in the current directory, and
puts its output files there, and so h2n is run from the
data directory.
Therefore h2n is run from the data
directory. h2n is a Perl program, by Liu and Albitz. It has been
modified to
Some changes have been made to h2n, to properly deal with large sites
and internal root domain
/var/named/zone
subdirectory, reverse files in the /var/named/rev
directory and any secondary backup files in /var/named/bak.
db.domain files will be removed (as well as
others) and h2n will start with a fresh slate.
There is another consequence of h2n's desire to read existing h2n
output files if any exist. h2n assumes that the first few lines of a
file of the form db.domain contain a SOA
record. This means we do not customise all files with a header comment
that warns that the file is machine generated as it would break
h2n. The only files which have this warning are the boot files however
the warning applies to all the files generated by DNStool.
db/options.generic. This file is in the format of
the parameters file for DNS configuration file builder, h2n. See Appendix B: h2n manual
page for a complete description of these options.
It is also possible to create options.${domain} files
for extra options pertaining to a particular domain. These options
are currently appended to the options specified in the
options.generic file.
This file enables features to be readily standardized across domains, such as the name servers, the time-to-live values of data, and contact information. The more standard the domains, the simpler the task of the DNStool (its sysadmin and programmer). At present the domains are made to be as uniform as possible. They have a common set of name servers, contact information, time-to-live data and default mx records.
Here is the current options.generic for the gormand.com.au domain
-h banana.gormand.com.au
-u hostmaster@gormand.com.au
-o 10800:3600:3600000:86400
-z 192.168.13.1
-s banana.gormand.com.au
-s bigted.gormand.com.au
-s hambyl.gormand.com.au
-m 10:mail.gormand.com.au
In brief, there are three public name servers
banana.gormand.com.au, bigted.gormand.com.au
and hambyl.gormand.com.au. Refer to Changing nameservers for more detail about
namserver types.
The Start of Authority record (the -u/o options to h2n) defines the
specified helpful person and authoritative host and time-to-live
periods. Secondary servers consult a certain host (specified by IP
address in the -z option) for data.
This file is used to generate an option file for each domain, which is given to h2n. The auto-configuration deduces additional options:
The network numbers are assumed to be those of subnets of a Class B network (in the form N.N.S), except for the internal root and top level domains which have a constant value.
Note that options.generic does not include the serial number in the SOA field. Instead, every time the DNStool is run, it generates a new serial number for the generated files (from the system time) ensuring that the information will propogate correctly.
h2n - Translate host table to name server file format
SYNOPSIS
h2n -d DOMAIN -n NET [options]
DESCRIPTION
h2n translates /etc/hosts to DNS files and creates a BIND boot file. This tool can be run once or many times. After converting your host table to DNS format, you can manually maintain the DNS files, or you can maintain the host table and run h2n each time you modify /etc/hosts. h2n automatically increments the serial number in each DNS file when it makes a new one.
h2n generates files starting with the prefix "db." These are called "db files." The domain data is stored in a file called db.DOMAIN, where DOMAIN is the first label in your domain name (given with the -d option). The address-to-name data is stored in files named db.NET, where NET is a network number (given with the -n option).
Each time h2n is run, it generates the DNS files from scratch. Any changes you manually made to the DNS files are lost. If you'd like to add resource records to a db file generated by h2n, put your RRs in a file prefixed with "spcl" instead of "db". h2n will include this file's data by adding a $INCLUDE directive to the end of the db file.
By default, h2n will generate an MX record with a weight of 10 that points to the host itself as the mail exchanger. MX records can be suppressed with -M. Additional MX records can be added with -m. To suppress generating the default MX record for a host, include "[no smtp]" in that host's host table comment. By default, h2n will create a boot file, ./boot.cacheonly, for a caching only name server. If either of the -z or -Z options are used, h2n creates a boot file, named ./boot.sec.save or ./boot.sec respectively, for a secondary name server.
Options are:
-m 10:terminator.movie.edu
-m20:wormhole
Example: -n 192.249.249 -n 15.15.16:255.255.248.0
h2n -d movie.edu -n 192.249.249 -n 192.253.253
h2n -f option_file
where option_file contains the following lines:
-d movie.edu
-n 192.249.249
-n 192.253.253
-e fx.movie.edu
-m 50:postmanrings2x.movie.edu
file = blank* (record | blank)*
blank = (^\s*$ | ^\s*[#;].*)
record = OPEN hostclause ipclause clause* CLOSE
hostclause = HOST EQUAL \w+
ipclause = IP EQUAL ipaddress+
ipaddress = \d+.\d+.\d+.\d+
clause = etherclause |
hostidclause |
listclause |
quotedclause |
wordclause
etherclause = ETHER EQUAL etheraddr
wordclause = plainkeyword EQUAL word
listclause = listkeyword EQUAL word+
quotedclause = quotekeyword EQUAL QUOTE .* QUOTE
etheraddr = hex:hex:hex:hex:hex:hex
word = \w+
hex = [A-Fa-z\d][A-Fa-z\d]?
listkeyword = ALIAS |
GLOBAL |
IP |
MX
quotekeyword = BARCODE |
COMMENT |
HARDWARE |
LOCATION |
OWNER |
OS |
SERIAL
plainkeyword = HOST |
HOSTID |
SERVER
ALIAS = alias | aliases
BARCODE = barcode
COMMENT = comment
ETHER = ether
GLOBAL = global | globals | globalalias | globalalias
HARDWARE = hw | hardware
IP = ip | ips
LOCATION = location
MX = mx
OWNER = owner
OS = os
SERVER = server
OPEN = {
CLOSE = }
EQUAL = =
QUOTE = "
Modifications by Dave Roberts to remove the restriction of one domain per subnet by running h2n in subdirectories. Many thanks Dave.
Additional tools in the bin directory from Peter Samuel and Mark Probert
h2n was written by Paul Albitz and Cricket Liu. Thanks
also for their excellent book DNS and BIND, O'Reilly and
Associates, ISBN 1-56592-010-4. Anyone managing a site using DNS
should have a copy of this book.
Testing, use and suggestions by system administrators from Telstra IBU Information Systems and Telstra Intelligent Network Development.
Additional feedback from Marc Jolly, Charles Butcher, Mark Pfeiffer and Peter Samuel.
Bugs, comments and suggestions to me: <Gordon Rowell>