
			    msql_bind 1.0
				  

msql_bind is an extension of BIND-4.9.3 which is maintained by Paul
Vixie (paul@vix.com).  mSQL is maintained by David Hughes
(bambi@bond.edu.au). msql_bind is maintained by Chris Seawood
(mgrcls@nextwork.rose-hulman.edu).

msql_bind loses none of the functionality of stock BIND, yet adds
features like adding machines, changing machine information, and
adding zones (not throughly tested), without having to restart your
named daemon or changing multiple .db files. (Note: adding zones
requires editing your /etc/named.boot) msql_bind can also be run
without using a db, but currently treats every entry as static,
defeating the purpose of msql_bind.

Requirements:
------------
msql_bind requires the mSQL package, preferably 1.0.5 or higher. The
latest version of mSQL can be found at bond.edu.au:/pub/Minerva/msql.


Files: 
------ 
model.bind : the basic tables needed to run msql
bind_admin : perl script to enter, remove, edit, and list dns entries.
zone_admin : perl script to enter, remove, edit, and list zone entries.
read_dnswalk : perl script to read axfr files generated by dnswalk 
dnswalk : perl script from bind 4.9.3 pkg, dumps current zone
          contents to a file
msql.dom : a sample .db file that contains a valid msql_bind line
bind-4.9.3-BETA24.950802.cdiff : patch against stock bind-4.9.3-BETA24


How it works:
------------

1.  You must have a mSQL database: `msqladmin create dbname`

2.  You must create the tables for msql_bind by using the model.bind 
    file: `msql dbname < model.bind` 
    *WARNING*: this will remove any existing tables with the names 
    msql_dns and msql_zones.

3.  Before you shutdown your existing named, you need to run dnswalk
    for each of your zones. (Ex: dnswalk rose-hulman.edu. , 
    dnswalk cs.rose-hulman.edu., etc.)

4.  You need to run read_dnswalk to place entries into your database.
    (Ex: read_dnswalk dbname cs.rose-hulman.edu. edu/rose-hulman/cs/axfr )

5.  You must edit your named.boot to reference msql.dom instead of
    your current .db files. Note: a msql_bind line can be used in any
    .db file at any place (after the SOA & NS records, of course), so that 
    you can use the database for only select entries.

Make sure that msqld is running on your choosen msqlserver and you are
all set.

Internals:
----------

This will/should contain all of the pertinent info about msql_bind.

The key element of msql_bind is time. The tables used by msql_bind are:
Note: the '\g' are commands to msql to complete a query, and are needed.

CREATE TABLE msql_dns (
        dns_entry       int             primary key,
        zoneid          int             not null,
        machine         char(40)        not null,
        class           char(10)        not null,
        type            char(10)        not null,
        info            char(127)       not null,
        assigned_time   int             not null,
        importance      int             not null,
        dynamic         int             not null
)
\g
 
CREATE TABLE msql_zones (
        name            char(40)        primary key,
        zoneid          int             not null
)
\g


The machine, class, type, and info fields are almost
self-explanatory. They mimic values used in flatfiles.

The zoneid field maps to a certain zone in the zones table. This
allows you to have query entries for local domai ns w/o having to use
the fqdn. For example, if I have the following row:
'purple',2,'IN','A','137.112.3.11',0,4,0 with zone entries
'nextwork.',2
'nextwork.rose-hulman.edu.',2
Then from the subdomain cs.rose-hulman.edu, I could lookup
purple.nextwork instead/in addition to purple.nextwork.rose-hulman.edu

Note: each domain must end with a "." msql_bind will *not* work otherwise

The key element behind msql_bind is the assigned_time field. All
updates are made based upon the value of this field verses the last
updated time. The bind_admin script automatically places the current
time whenever you add or edit an entry.

The importance field is used to distinguish between different types of
entries. SOA entries have importance of 1, NS -- 2, other records for
the SOA table (A is the only one that comes to mind) -- 3, everything
else 4.

The dynamic field is self-explanatory. The reason it is used is to
remove the old entries (if it can find them) from the cache, before it
adds new entries. Otherwise, you'll have multiple A record for one
host. This is alright for your multi-homed machines, but for laptop on
the move, it's disasterous.



Changes were made to the following files:

conf/options.h : added #define MSQL
named/db_defs.h : added d_dynamic to struct databuf
named/db_load.c : added routines to db_load() to read from msql db
named/db_update.c : added code to remove duplicate entries
		    if d_dynamic flag is set
named/ns_defs.h : added z_db* entries to struct zoneinfo
named/ns_glob.h : added global usingMsql var.
named/ns_init.c : added msql_update_check()
named/ns_maint.c : added code to query db at a given rate, and reload
		   the nameserver after another period of time


