.TH NDB 8
.SH NAME
query, mkhash, mkdb, cs, csquery, dns, dnsquery \- network database
.SH SYNOPSIS
.B ndb/query
.I "attr value"
[
.I rattr
]
.br
.B ndb/mkhash
.I "file attr"
.br
.B ndb/cs
[
.B -n
] [
.B -f
.I dbfile
]
.br
.B ndb/csquery
.br
.B ndb/dns
[
.B -s
] [
.B -f
.I dbfile
]
.br
.B ndb/dnsquery
.br
.B ndb/mkdb
.SH DESCRIPTION
The network database holds administrative information used by
network programs such as
.IR bootp (8),
.IR ipconfig (8),
.IR con (1),
etc.
.PP
.I Ndb/query 
searches the database for an attribute of type
.I attr
and value
.IR value .
If
.I rattr
is not specified, all entries matched by the search are returned.
If 
.I rattr
is specified, the value of the first pair with attribute
.I rattr
of all the matched entries is returned.
.PP
.I Ndb/mkhash
creates a hash file for all entries with attribute
.I attr
in database file
.IR file .
The hash files are used by 
.I ndb/query
and by the ndb library routines.
.PP
.I Ndb/cs
is a server used by
.IR dial (2)
to translate network names.
Option
.B -f
supplies the name of the data base file to use,
default
.BR /lib/ndb/local .
It is started at boot time.
It finds out what networks are configured
by looking for
.B /net/*/clone
when it starts.
It can also be told about networks by writing
to
.B /net/cs
a message of the form:
.IP
.B "add net1 net2 ..."
.PP
.I Ndb/cs
also sets the system name in
.B /dev/sysname
if it can figure it out.
Option
.B -n
causes cs to do nothing but set the system name.
.I Ndb/csquery
can be used to query
.I ndb/cs
to see how it resolves addresses.
.I Ndb/csquery
prompts for addresses and prints out what
.I ndb/cs
returns.
.PP
.I Ndb/dns
is a server used by
.I ndb/cs
and by remote systems to translate Internet domain names.
.I Ndb/dns
is started at boot time.
By default
.I dns
serves only requests written to
.BR /net/dns .
Option
.B -s
causes the server to also answer domain requests sent to UDP port 53.
Name resolution is performed by searching the local database
and by querying remote servers.
The server for a domain is indicated by a database entry containing
both a
.I dom
and a
.I ns
attribute.
For example, the entry for the Internet root is:
.EX

dom=
	ns=ns.nic.ddn.mil
	ns=kava.nisc.sri.com
	ns=aos.brl.mil

.EE
The root of a domain subtree served by the local database is indicated
by an entry with an
.I soa
attribute.
For example, the AT&T research domain is:
.EX

dom=research.att.com soa
	mb=ches.research.att.com
	ns=inet.research.att.com
	ns=research.research.att.com

.EE
Here, the
.I mb
entry is the mail address of the person responsible for the
domain (default
.BR postmaster ).
Wild-carded domain names can also be used.
For example, to specify a mail forwarder for all AT&T research systems:
.EX

dom=*.research.att.com
	mx=research.att.com

.EE
.I Ndb/dnsquery
can be used to query
.I ndb/dns
to see how it resolves requests.
.I Ndb/dnsquery
prompts for commands of the form
.IP
.I "domain-name request-type"
.LP
where
.I request-type
can be
.IR "ip, mx, ns, cname, ptr..." .
In the case of the inverse query type,
.IR ptr ,
.I dnsquery
will reverse the ip address and tack on the
.B .in-addr.arpa
for you.
.PP
.I Ndb/mkdb
is used in concert with
.IR awk (1)
scripts to convert
uucp systems files, IP host files, and Datakit configuration
files into database files.
It is very specific to the situation at Murray Hill.
.PP
When the database files change underfoot,
.I ndb/cs
and
.I ndb/dns
track them properly.  Nonetheless, to keep the database searches efficient
it is necessary to run
.I ndb/mkhash
whenever the files are modified.
It may be profitable to control this by a frequent
.IR cron (8)
job.
.SH EXAMPLES
.EX
% ndb/query sys helix
sys=helix dom=helix.research.att.com bootf=/mips/9powerboot
	ip=135.104.117.31 ether=080069020427
	dk=nj/astro/helix
	proto=il 
% ndb/query sys helix ip
135.104.117.31
% ndb/dnsquery
> 9net.research.att.com ip
9net.research.att.com ip	192.20.225.252
> 192.20.225.252 ptr
252.225.20.192.in-addr.arpa ptr	9net.research.att.com
> 
.EE
.SH FILES
.TF /lib/ndb/local.*xxx
.TP
.B /lib/ndb/local
first database file searched
.TP
.B /lib/ndb/local.*
hash files for
.B /lib/ndb/local
.TP
.B /srv/cs
service file for
.I ndb/cs
.TP
.B /net/cs
where
.B /srv/cs
gets mounted
.TP
.B /srv/dns
service file for
.I ndb/dns
.TP
.B /net/dns
where
.B /srv/dns
gets mounted
.SH SOURCE
.B /sys/src/cmd/ndb
.SH SEE ALSO
.IR ndb (2)
.IR ndb (6)
