Home | History | Annotate | Line # | Download | only in driver
      1 <!--
      2 Copyright (C) Internet Systems Consortium, Inc. ("ISC")
      3 
      4 SPDX-License-Identifier: MPL-2.0 and ISC
      5 
      6 This Source Code Form is subject to the terms of the Mozilla Public
      7 License, v. 2.0.  If a copy of the MPL was not distributed with this
      8 file, you can obtain one at https://mozilla.org/MPL/2.0/.
      9 
     10 See the COPYRIGHT file distributed with this work for additional
     11 information regarding copyright ownership.
     12 
     13 Copyright (C) Red Hat
     14 
     15 Permission to use, copy, modify, and/or distribute this software for any
     16 purpose with or without fee is hereby granted, provided that the above
     17 copyright notice and this permission notice appear in all copies.
     18 
     19 THE SOFTWARE IS PROVIDED "AS IS" AND AUTHORS DISCLAIMS ALL WARRANTIES WITH
     20 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
     21 AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
     22 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
     23 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
     24 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
     25 PERFORMANCE OF THIS SOFTWARE.
     26 -->
     27 
     28 To use the Dynamic DB sample driver, run named and check the log.
     29 
     30     $ cd testing
     31     $ named -gc named.conf
     32 
     33 You should be able to see something like:
     34 
     35 zone test/IN: loaded serial 0
     36 zone arpa/IN: loaded serial 0
     37 
     38 This means that the sample driver created empty zones "test." and
     39 "arpa." as defined by "arg" parameters in named.conf.
     40 
     41 $ dig @localhost test.
     42 
     43 should work as usual and you should be able to see the dummy zone with
     44 NS record pointing to the zone apex and A record with 127.0.0.1:
     45 
     46 ;; ANSWER SECTION:
     47 test.			86400	IN	A	127.0.0.1
     48 test.			86400	IN	NS	test.
     49 test.			86400	IN	SOA	test. test. 0 28800 7200 604800 86400
     50 
     51 This driver creates two empty zones and allows query/transfer/update to
     52 all IP addresses for demonstration purposes.
     53 
     54 The driver wraps the RBT database implementation used natively by BIND,
     55 and modifies the addrdataset() and substractrdataset() functions to do
     56 additional work during dynamic updates.
     57 
     58 A dynamic update modifies the target zone as usual. After that, the
     59 driver detects whether the modified RR was of type A or AAAA, and if so,
     60 attempts to appropriately generate or delete a matching PTR record in
     61 one of the two zones managed by the driver.
     62 
     63 E.g.:
     64 
     65 $ nsupdate
     66 > update add a.test. 300 IN A 192.0.2.1
     67 > send
     68 
     69 will add the A record
     70 a.test.			300	IN	A	192.0.2.1
     71 
     72 and also automatically generate the PTR record
     73 1.2.0.192.in-addr.arpa.	300	IN	PTR	a.test.
     74 
     75 AXFR and RR deletion via dynamic updates should work as usual. Deletion
     76 of a type A or AAAA record should delete the corresponding PTR record
     77 too.
     78 
     79 The zone is stored only in memory, and all changes will be lost on
     80 reload/reconfig.
     81 
     82 Hints for code readers:
     83 - Driver initialization starts in driver.c: dyndb_init() function.
     84 - New database implementation is registered by calling dns_db_register()
     85   and passing a function pointer to it. This sample uses the function
     86   create_db() to initialize the database.
     87 - Zones are created later in instance.c: load_sample_instance_zones().
     88 - Database entry points are in structure db.c: dns_dbmethods_t
     89   sampledb_methods
     90 - sampledb_methods points to an implementation of the database interface.
     91   See the db.c: addrdataset() implementation and look at how the RBT
     92   database instance is wrapped into an additional layer of logic.
     93