4a53e3c2b83c476a93148eaee0272649beb221caMark AndrewsCopyright (C) 2000, 2001, 2004, 2016 Internet Systems Consortium, Inc. ("ISC")
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntThis Source Code Form is subject to the terms of the Mozilla Public
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntLicense, v. 2.0. If a copy of the MPL was not distributed with this
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntfile, You can obtain one at http://mozilla.org/MPL/2.0/.
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntUsing the BIND 9 Simplified Database Interface
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntThis document describes the care and feeding of the BIND 9 Simplified
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntDatabase Interface, which allows you to extend BIND 9 with new ways
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntof obtaining the data that is published as DNS zones.
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntThe Original BIND 9 Database Interface
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntBIND 9 has a well-defined "back-end database interface" that makes it
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntpossible to replace the component of the name server responsible for
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntthe storage and retrieval of zone data, called the "database", on a
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntper-zone basis. The default database is an in-memory, red-black-tree
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntdata structure commonly referred to as "rbtdb", but it is possible to
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntwrite drivers to support any number of alternative database
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunttechnologies such as in-memory hash tables, application specific
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntpersistent on-disk databases, object databases, or relational
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntThe original BIND 9 database interface defined in <dns/db.h> is
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntdesigned to efficiently support the full set of database functionality
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntneeded by a name server that implements the complete DNS protocols,
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntincluding features such as zone transfers, dynamic update, and DNSSEC.
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntEach of these aspects of name server operations places its own set of
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntdemands on the data store, with the result that the database API is
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntquite complex and contains operations that are highly specific to the
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntDNS. For example, data are stored in a binary format, the name space
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntis tree structured, and sets of data records are conceptually
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntassociated with DNSSEC signature sets. For these reasons, writing a
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntdriver using this interface is a highly nontrivial undertaking.
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntThe Simplified Database Interface
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntMany BIND users wish to provide access to various data sources through
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntthe DNS, but are not necessarily interested in completely replacing
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntthe in-memory "rbt" database or in supporting features like dynamic
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntupdate, DNSSEC, or even zone transfers.
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntOften, all you want is limited, read-only DNS access to an existing
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntsystem. For example, you may have an existing relational database
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntcontaining hostname/address mappings and wish to provide forvard and
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntreverse DNS lookups based on this information. Or perhaps you want to
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntset up a simple DNS-based load balancing system where the name server
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntanswers queries about a single DNS name with a dynamically changing
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntset of A records.
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntBIND 9.1 introduced a new, simplified database interface, or "sdb",
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntwhich greatly simplifies the writing of drivers for these kinds of
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntapplications.
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntThe sdb Driver
ef421f66f47224a42073deaf087378c5d0c9952eEvan HuntAn sdb driver is an object module, typically written in C, which is
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntlinked into the name server and registers itself with the sdb
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntsubsystem. It provides a set of callback functions, which also serve
ef421f66f47224a42073deaf087378c5d0c9952eEvan Huntto advertise its capabilities. When the name server receives DNS
4a53e3c2b83c476a93148eaee0272649beb221caMark Andrewsqueries, invokes the callback functions to obtain the data to respond
bind9/lib/dns/include/dns/sdb.h. For example drivers, see
add timedb.c to DBDRIVER_SRCS and timedb.@O@ to DBDRIVER_OBJS). If
e.g. timedb_init() and timedb_clear() for the timedb sample sdb
driver) must be inserted into the server, in bind9/bin/named/main.c.
in its "zone" statement in named.conf. For example, if the driver
zone "foo.com" {
zone "foo.com" {