⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sdb

📁 bind-3.2.
💻
字号:
Copyright (C) 2000, 2001  Internet Software Consortium.See COPYRIGHT in the source root or http://isc.org/copyright.html for terms.Using the BIND 9 Simplified Database InterfaceThis document describes the care and feeding of the BIND 9 SimplifiedDatabase Interface, which allows you to extend BIND 9 with new waysof obtaining the data that is published as DNS zones.The Original BIND 9 Database InterfaceBIND 9 has a well-defined "back-end database interface" that makes itpossible to replace the component of the name server responsible forthe storage and retrieval of zone data, called the "database", on aper-zone basis.  The default database is an in-memory, red-black-treedata structure commonly referred to as "rbtdb", but it is possible towrite drivers to support any number of alternative databasetechnologies such as in-memory hash tables, application specificpersistent on-disk databases, object databases, or relationaldatabases.The original BIND 9 database interface defined in <dns/db.h> isdesigned to efficiently support the full set of database functionalityneeded by a name server that implements the complete DNS protocols,including features such as zone transfers, dynamic update, and DNSSEC.Each of these aspects of name server operations places its own set ofdemands on the data store, with the result that the database API isquite complex and contains operations that are highly specific to theDNS.  For example, data are stored in a binary format, the name spaceis tree structured, and sets of data records are conceptuallyassociated with DNSSEC signature sets.  For these reasons, writing adriver using this interface is a highly nontrivial undertaking.The Simplified Database InterfaceMany BIND users wish to provide access to various data sources throughthe DNS, but are not necessarily interested in completely replacingthe in-memory "rbt" database or in supporting features like dynamicupdate, DNSSEC, or even zone transfers.Often, all you want is limited, read-only DNS access to an existingsystem.  For example, you may have an existing relational databasecontaining hostname/address mappings and wish to provide forvard andreverse DNS lookups based on this information.  Or perhaps you want toset up a simple DNS-based load balancing system where the name serveranswers queries about a single DNS name with a dynamically changingset of A records.BIND 9.1 introduced a new, simplified database interface, or "sdb",which greatly simplifies the writing of drivers for these kinds ofapplications.The sdb DriverAn sdb driver is an object module, typically written in C, which islinked into the name server and registers itself with the sdbsubsystem.  It provides a set of callback functions, which also serveto advertise its capabilities.  When the name server receives DNSqueries, invokes the callback functions to obtain the data to respondwith.Unlike the full database interface, the sdb interface represents alldomain names and resource records as ASCII text.Writing an sdb DriverWhen a driver is registered, it specifies its name, a list of callbackfunctions, and flags.The flags specify whether the driver wants to use relative domainnames where possible.The callback functions are as follows.  The only one that must bedefined is lookup().  - create(zone, argc, argv, driverdata, dbdata)	  Create a database object for "zone".  - destroy(zone, driverdata, dbdata)	  Destroy the database object for "zone".  - lookup(zone, name, dbdata, lookup)	  Return all the records at the domain name "name".  - authority(zone, dbdata, lookup)	  Return the SOA and NS records at the zone apex.  - allnodes(zone, dbdata, allnodes)	  Return all data in the zone, for zone transfers.For more detail about these functions and their parameters, seebind9/lib/dns/include/dns/sdb.h.  For example drivers, seebind9/contrib/sdb.Rebuilding the ServerThe driver module and header file must be copied to (or linked into)the bind9/bin/named and bind9/bin/named/include directoriesrespectively, and must be added to the DBDRIVER_OBJS and DBDRIVER_SRCSlines in bin/named/Makefile.in (e.g. for the timedb sample sdb driver,add timedb.c to DBDRIVER_SRCS and timedb.@O@ to DBDRIVER_OBJS).  Ifthe driver needs additional header files or libraries in nonstandardplaces, the DBDRIVER_INCLUDES and DBDRIVER_LIBS lines should also beupdated.Calls to dns_sdb_register() and dns_sdb_unregister() (or wrappers,e.g. timedb_init() and timedb_clear() for the timedb sample sdbdriver) must be inserted into the server, in bind9/bin/named/main.c.Registration should be in setup(), before the call tons_server_create().  Unregistration should be in cleanup(),after the call to ns_server_destroy().  A #include should be addedcorresponding to the driver header file.You should try doing this with one or more of the sample driversbefore attempting to write a driver of your own.Configuring the ServerTo make a zone use a new database driver, specify a "database" optionin its "zone" statement in named.conf.  For example, if the driverregisters itself under the name "acmedb", you might say   zone "foo.com" {	   database "acmedb";   };You can pass arbitrary arguments to the create() function of thedriver by adding any number of whitespace-separated words after thedriver name:   zone "foo.com" {	   database "acmedb -mode sql -connect 10.0.0.1";   };Hints for Driver Writers - If a driver is generating data on the fly, it probably should   not implement the allnodes() function, since a zone transfer   will not be meaningful.  The allnodes() function is more relevant   with data from a database. - The authority() function is necessary if and only if the lookup()   function will not add SOA and NS records at the zone apex.  If   SOA and NS records are provided by the lookup() function,   the authority() function should be NULL. - When a driver is registered, an opaque object can be provided.  This   object is passed into the database create() and destroy() functions. - When a database is created, an opaque object can be created that   is associated with that database.  This object is passed into the   lookup(), authority(), and allnodes() functions, and is   destroyed by the destroy() function.Future DirectionsA future release may support dynamic loading of sdb drivers.$Id: sdb,v 1.5 2001/05/30 23:02:03 bwelling Exp $

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -