.\" Generated by Mmark Markdown Processor - mmark.miek.nl .TH "DBSQLITE" 7 "August 2026" "atomdns handlers" "atomdns authors" .SH "NAME" .PP \fIdbsqilte\fP \- serve zone data from a SQLite database .SH "DESCRIPTION" .PP The \fIdbsqlite\fP handler reads zone data from a data and serves that to clients. If the database contains signatures (i.e. is signed using DNSSEC), correct DNSSEC answers are returned. Only NSEC is supported. You can create the database completely off\-line, if it holds the correct data, \fIdbsqlite\fP will happily serve from it. .PP The \fIsign\fP handler does \fInot\fP support databases, so you need something like ldns\-signzone to sign and resign your zones and put the generated records in the database. .PP When started the database file will be created and the schema will be written to it (if it does not already exist). After this step, the handler will never write to the database, for the purpose of generating answers the database is completely read\-only. The database can be prepared beforehand. .PP An RR that fails to be converted into a proper \fB\fCdns.RR\fR is silently discarded, unless \fB\fCdebug\fR is active, see atomdns\-global(7) for details. The class is \fB\fCIN\fR and can't be overridden. .PP When atomdns starts up the \fIdbsqlite\fP handler will log how many zones it found in the database, this is a live query and may differ with the zones specified in the configuration. .PP The server will reply with minimal responses by default. .SH "DATABASE" .PP The schema used for the database is: .PP .RS .nf CREATE TABLE rrs ( name VARCHAR(255), type VARCHAR(10), data VARCHAR(65535), ttl INTEGER, UNIQUE (name, type, data) ); .fi .RE .PP You can just add RRs to this table for \fIany\fP zone and \fIdbsqlite\fP will happily use them. Relative names will be made not be made into fully qualified ones, and for some queries that will not be matched and silently \fInot\fP included. .PP .RS .nf sqlite> insert into rrs values ( '\_ssh.\_tcp.host1.example.', 'srv', '10 5 43 example', 3600); sqlite> insert into rrs values ( 'subdel.example', 'ns', 'ns.example.com', 3600); .fi .RE .PP This one database can be safely used for all zones you have. Note that you still have to make sure the handler gets queries for new zones. .SS "IMPORTING ZONE FILES" .PP If you have a zone file you can use the \fB\fC.import\fR feature of SQLite to import the file in one go using the excellent "ldns" utils from NLnet Labs (https://www.nlnetlabs.nl/projects/ldns/about/). .PP .RS .nf ldns\-read\-zone db.example.org | sed 's/;.*$//' | sed 's/ $//' | \\ awk '{print $1 "," $4 "," substr($0, index($0, $5)) "," $2}' > csv.example.org .fi .RE .PP And then: .PP .RS .nf sqlite3 /tmp/db < .mode csv heredoc> BEGIN; heredoc> .import csv.example.org rrs heredoc> COMMIT; heredoc> EOF .fi .RE .PP Where the \fB\fCldns-read-zone\fR pipeline removes trailing white space, and the helpful comments after DNSKEY records, then \fB\fCawk\fR re\-arranges it into the proper format. .SH "SYNTAX" .PP In it simplest form \fIdbsqlite\fP you can use: .PP .RS .nf dbsqlite DATABASE .fi .RE .IP \(bu 4 \fBDATABASE\fP the file with the SQLite database to query. If the path is relative, the path from the global root config will be prepended to it. .PP If \fBDATABASE\fP does not exists the file is created and the \fB\fCrrs\fR table is initialized. .PP For extra control you can open the block and define multiple extra properties that deal with zone transfers. Only outgoing zone transfers are supported. It is similar to \fIdbfile\fP, and we refer to that documentation then to repeat it here. .PP .RS .nf dbsqlite DATABASE { transfer { to [IP[:PORT]]... { notify IP[:PORT] [IP[:PORT]]... source IP [IP]... key NAME ALGORITHM SECRET } } } .fi .RE .SH "EXAMPLES" .PP Have both \fB\fCexample.org\fR and \fB\fCexample.net\fR read from the same database. .PP .RS .nf example.org example.net { dbsqlite example.db } .fi .RE .PP If you want \fIeverything\fP to end up in \fIdbsqlite\fP, you might be tempted to: .PP .RS .nf \&. { dbsqlite root.db } .fi .RE .PP But this fails, \fIunless\fP you are actually authoritative for \fB\fC.\fR (the root zone), this because the named zones are used to find those in the database.