dns – Build dns maps from /etc/hosts
dns [ -rbW] [-H hosts-file] [config-file]
dns
is used to prepare named(8)
maps for a nameserving machine.
It takes a small configuration file (or, alternatively, standard
input) and uses it and the contents of your /etc/hosts
file to
build zone maps.
The dns
program uses a dns
configuration file that contains a
list of interesting commands describing things you might want to
have in your dns maps. It also picks apart /etc/hosts
for the
dns information of the various sites in your domain. By default,
dns
generates map files for your domain and your loopback domain
and writes them into your current directory; if you specify the
-b
option, it will also generate named.boot
in your current
directory. If you specify the -W
option, dns
will generate
the map files in your database
(see below) directory. Finally,
dns
will attempt to signal named(8)
of the changed dns database
if you give the -r
option.
If you don’t wish to build maps from /etc/hosts
you can tell dns
a
different hosts file by the -H
option.
The commands you can specify in the config-file are as follows:
domain
domain-namelocalhost.zone
for
your
loopback
IN-ADDR.ARPA
map,
and domain-name.zone
for your domain map. This command
is required to generate dns maps.network
addressIN-ADDR.ARPA
map for your network (this map includes
all entries in /etc/hosts
that are in the given network.)site
machine-name.zone
. You must give a authoritative
site to generate dns records.contact
nameroot@
site, set it here.nameserver
nameprivate-mail
YES
or NO
NO
, every machine in this domain gets MX records; if
set to YES
, mail directly to the machine is allowed.postoffice
nameroothost
nametelnet
or ftp
into your domain go to this
machine instead of simply failing.alias-domain
namealias-name
alias-ip
/etc/hosts
aliases are handled; dns
generates dns records for every alias in /etc/hosts
, but
generates CNAME
records if you’ve set alias-name
and A
records if you’ve set alias-ip
.database
directory-W
command-line option, write the completed
maps to the given directory
. Note that the named.boot
file will still be written to /etc
no matter what directory
you give. If you do not specify a database
directory, the
maps will be written (subject to -W
) to the directory
/var/namedb
.secondary
domain addressesAct as a secondary nameserver for domain, where its primary nameservers are at the given addresses. This is useful if you’re at one end of a slow or intermittent IP connection and don’t want to spend the time constantly fetching dns information for frequently queried sites.
If the secondary domain is instead a network address, generate
an IN-ADDR.ARPA
map for it.
Say I’ve got the domain tsfr.org
that I’d like to do nameserving
for. I’ve also inherited the domain evilparty.org
, which I’m
planning on using as an alias for tsfr.org
, and I’m doing secondary
nameservice for the www.pell.portland.or.us/~mastodon
domain.
My /etc/hosts
looks like this (note that these IP addresses WILL NOT
WORK in real life, since they are actually reserved multicast
addresses):
# /etc/hosts
# This file contains the ip addresses and names of your host
# and of other machines. The format is
#
#nnn.nnn.nnn.nnn fully qualified name hostname [ aliases ]
#
127.0.0.1 localhost loopback
224.1.1.1 central.tsfr.org foo news postoffice
224.1.1.2 right.tsfr.org right
224.1.1.3 left.tsfr.org left
224.1.1.4 gateway.tsfr.org gateway www ftp usenet
225.1.1.5 remote.tsfr.org remote
#
226.1.1.1 interesting.site.com
227.1.1.1 woo-woo-woo.www.pell.portland.or.us/~mastodon
and the configuration file tsfr.dns
looks like this:
domain tsfr.org ; our domain
network 224.1.1 ; and our network
site gateway
contact henry
nameserver gateway
nameserver central
postoffice 10 postoffice
postoffice 20 gateway
postoffice 800 central
roothost gateway
alias-domain evilparty.org
alias-name
database /var/namedb
secondary www.pell.portland.or.us/~mastodon 226.1.1.1
Running dns -b tsfr.dns
generates the following files in the
current directory: tsfr.org.zone
,evilparty.org.alias
(the alias
map that’s mainly a PTR to tsfr.org), tsfr.org.rev
(the IN-ADDR.ARPA
map for our domain), localhost.zone
(the IN-ADDR.ARPA
map for
the loopback interface), and named.boot
, which looks like this:
; domain tsfr.org
; data file to boot a name server
; generated by dns on Mon May 6 00:50:15 1996
;
directory /var/namedb
;
; type domain/zone host/file local-file
;
cache . named.cache
primary 0.0.127.IN-ADDR.ARPA localhost.zone
primary 1.1.224.IN-ADDR.ARPA tsfr.org.rev
primary tsfr.org tsfr.org.zone
primary evilparty.org evilparty.org.alias
; domains we do secondary nameservice for
;
secondary www.pell.portland.or.us/~mastodon 226.1.1.1 mastodon.biz.bak
Errors abort the program and return a non-zero exit status.
Written by Jessica L. Parsons to simplify setting up new nameservers for the pell.portland.or.us, psgvb.com, and pell.com domains.
If named(8)
is not running, the -r
option will have no effect.
The serial number in SOA records is formed from the year since
the epoch (1970
), the julian day, and the number of minutes
since midnight divided by two. If you quickly change maps with
dns
, the serial number will NOT
update, thus leading to
confused remote nameservers.
Makefile, sample/tsfr.org.rev, dns.8, sample/localhost.zone, sample/named.boot, dns.c, sample/tsfr.org.zone, sample/hosts, and sample/evilparty.org.alias.