Debian Codegraph @

cmd/atomdns/man/atomdns-dbsqlite.7

raw
1 .\" Generated by Mmark Markdown Processor - mmark.miek.nl
2 .TH "DBSQLITE" 7 "August 2026" "atomdns handlers" "atomdns authors"
3
4 .SH "NAME"
5 .PP
6 \fIdbsqilte\fP \- serve zone data from a SQLite database
7
8 .SH "DESCRIPTION"
9 .PP
10 The \fIdbsqlite\fP handler reads zone data from a data and serves that to clients. If the database contains
11 signatures (i.e. is signed using DNSSEC), correct DNSSEC answers are returned. Only NSEC is supported. You can
12 create the database completely off\-line, if it holds the correct data, \fIdbsqlite\fP will happily serve from it.
13
14 .PP
15 The \fIsign\fP handler does \fInot\fP support databases, so you need something like ldns\-signzone to sign and resign
16 your zones and put the generated records in the database.
17
18 .PP
19 When started the database file will be created and the schema will be written to it (if it does not already
20 exist). After this step, the handler will never write to the database, for the purpose of generating answers
21 the database is completely read\-only. The database can be prepared beforehand.
22
23 .PP
24 An RR that fails to be converted into a proper \fB\fCdns.RR\fR is silently discarded, unless \fB\fCdebug\fR is active, see
25 atomdns\-global(7) for details. The class is \fB\fCIN\fR and can't be overridden.
26
27 .PP
28 When atomdns starts up the \fIdbsqlite\fP handler will log how many zones it found in the database, this is a live
29 query and may differ with the zones specified in the configuration.
30
31 .PP
32 The server will reply with minimal responses by default.
33
34 .SH "DATABASE"
35 .PP
36 The schema used for the database is:
37
38 .PP
39 .RS
40
41 .nf
42 CREATE TABLE rrs (
43 name VARCHAR(255),
44 type VARCHAR(10),
45 data VARCHAR(65535),
46 ttl INTEGER,
47 UNIQUE (name, type, data)
48 );
49
50 .fi
51 .RE
52
53 .PP
54 You can just add RRs to this table for \fIany\fP zone and \fIdbsqlite\fP will happily use them. Relative names will be
55 made not be made into fully qualified ones, and for some queries that will not be matched and silently \fInot\fP included.
56
57 .PP
58 .RS
59
60 .nf
61 sqlite> insert into rrs values ( '\_ssh.\_tcp.host1.example.', 'srv', '10 5 43 example', 3600);
62 sqlite> insert into rrs values ( 'subdel.example', 'ns', 'ns.example.com', 3600);
63
64 .fi
65 .RE
66
67 .PP
68 This one database can be safely used for all zones you have. Note that you still have to make sure the handler
69 gets queries for new zones.
70
71 .SS "IMPORTING ZONE FILES"
72 .PP
73 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
74 excellent "ldns" utils from NLnet Labs (https://www.nlnetlabs.nl/projects/ldns/about/).
75
76 .PP
77 .RS
78
79 .nf
80 ldns\-read\-zone db.example.org | sed 's/;.*$//' | sed 's/ $//' | \\
81 awk '{print $1 "," $4 "," substr($0, index($0, $5)) "," $2}' > csv.example.org
82
83 .fi
84 .RE
85
86 .PP
87 And then:
88
89 .PP
90 .RS
91
92 .nf
93 sqlite3 /tmp/db <<EOF
94 heredoc> .mode csv
95 heredoc> BEGIN;
96 heredoc> .import csv.example.org rrs
97 heredoc> COMMIT;
98 heredoc> EOF
99
100 .fi
101 .RE
102
103 .PP
104 Where the \fB\fCldns-read-zone\fR pipeline removes trailing white space, and the helpful comments after DNSKEY
105 records, then \fB\fCawk\fR re\-arranges it into the proper format.
106
107 .SH "SYNTAX"
108 .PP
109 In it simplest form \fIdbsqlite\fP you can use:
110
111 .PP
112 .RS
113
114 .nf
115 dbsqlite DATABASE
116
117 .fi
118 .RE
119
120 .IP \(bu 4
121 \fBDATABASE\fP the file with the SQLite database to query. If the path is relative, the path from the global root config will be
122 prepended to it.
123
124
125 .PP
126 If \fBDATABASE\fP does not exists the file is created and the \fB\fCrrs\fR table is initialized.
127
128 .PP
129 For extra control you can open the block and define multiple extra properties that deal with zone transfers. Only outgoing zone
130 transfers are supported.
131 It is similar to \fIdbfile\fP, and we refer to that documentation then to repeat it here.
132
133 .PP
134 .RS
135
136 .nf
137 dbsqlite DATABASE {
138 transfer {
139 to [IP[:PORT]]... {
140 notify IP[:PORT] [IP[:PORT]]...
141 source IP [IP]...
142 key NAME ALGORITHM SECRET
143 }
144 }
145 }
146
147 .fi
148 .RE
149
150 .SH "EXAMPLES"
151 .PP
152 Have both \fB\fCexample.org\fR and \fB\fCexample.net\fR read from the same database.
153
154 .PP
155 .RS
156
157 .nf
158 example.org example.net {
159 dbsqlite example.db
160 }
161
162 .fi
163 .RE
164
165 .PP
166 If you want \fIeverything\fP to end up in \fIdbsqlite\fP, you might be tempted to:
167
168 .PP
169 .RS
170
171 .nf
172 \&. {
173 dbsqlite root.db
174 }
175
176 .fi
177 .RE
178
179 .PP
180 But this fails, \fIunless\fP you are actually authoritative for \fB\fC.\fR (the root zone), this because the named zones are
181 used to find those in the database.