]> git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/dnsdistdist/docs/reference/config.rst
Merge pull request #8400 from pieterlexis/centos-8-pkgs
[thirdparty/pdns.git] / pdns / dnsdistdist / docs / reference / config.rst
1 .. highlight:: lua
2
3 Configuration Reference
4 =======================
5
6 This page lists all configuration options for dnsdist.
7
8 .. note::
9
10 When an IPv6 IP:PORT combination is needed, the bracketed syntax from :rfc:`RFC 3986 <3986#section-3.2.2>` should be used.
11 e.g. "[2001:DB8:14::C0FF:FEE]:5300".
12
13 Functions and Types
14 -------------------
15
16 Within dnsdist several core object types exist:
17
18 * :class:`Server`: generated with :func:`newServer`, represents a downstream server
19 * :class:`ComboAddress`: represents an IP address and port
20 * :class:`DNSName`: represents a domain name
21 * :class:`NetmaskGroup`: represents a group of netmasks
22 * :class:`QPSLimiter`: implements a QPS-based filter
23 * :class:`SuffixMatchNode`: represents a group of domain suffixes for rapid testing of membership
24 * :class:`DNSHeader`: represents the header of a DNS packet, see :ref:`DNSHeader`
25 * :class:`ClientState`: sometimes also called Bind or Frontend, represents the addresses and ports dnsdist is listening on
26
27 The existence of most of these objects can mostly be ignored, unless you plan to write your own hooks and policies, but it helps to understand an expressions like:
28
29 .. code-block:: lua
30
31 getServer(0).order=12 -- set order of server 0 to 12
32 getServer(0):addPool("abuse") -- add this server to the abuse pool
33
34 The ``.`` means ``order`` is a data member, while the ``:`` means ``addPool`` is a member function.
35
36 Global configuration
37 --------------------
38
39 .. function:: includeDirectory(path)
40
41 Include configuration files from ``path``.
42
43 :param str path: The directory to load configuration files from. Each file must end in ``.conf``.
44
45 .. function:: reloadAllCertificates()
46
47 .. versionadded:: 1.4.0
48
49 Reload all DNSCrypt and TLS certificates, along with their associated keys.
50
51 .. function:: setSyslogFacility(facility)
52
53 .. versionadded:: 1.4.0
54
55 Set the syslog logging facility to ``facility``.
56
57 :param int facility: The new facility as a numeric value. Defaults to LOG_DAEMON.
58
59 Listen Sockets
60 ~~~~~~~~~~~~~~
61
62 .. function:: addLocal(address[, options])
63
64 .. versionadded:: 1.2.0
65
66 .. versionchanged:: 1.3.0
67 Added ``cpus`` to the options.
68
69 .. versionchanged:: 1.4.0
70 Removed ``doTCP`` from the options. A listen socket on TCP is always created.
71
72 Add to the list of listen addresses.
73
74 :param str address: The IP Address with an optional port to listen on.
75 The default port is 53.
76 :param table options: A table with key: value pairs with listen options.
77
78 Options:
79
80 * ``doTCP=true``: bool - Also bind on TCP on ``address``. Removed in 1.4.0.
81 * ``reusePort=false``: bool - Set the ``SO_REUSEPORT`` socket option.
82 * ``tcpFastOpenQueueSize=0``: int - Set the TCP Fast Open queue size, enabling TCP Fast Open when available and the value is larger than 0.
83 * ``interface=""``: str - Set the network interface to use.
84 * ``cpus={}``: table - Set the CPU affinity for this listener thread, asking the scheduler to run it on a single CPU id, or a set of CPU ids. This parameter is only available if the OS provides the pthread_setaffinity_np() function.
85
86 .. code-block:: lua
87
88 addLocal('0.0.0.0:5300', { reusePort=true })
89
90 This will bind to both UDP and TCP on port 5300 with SO_REUSEPORT enabled.
91
92 .. function:: addLocal(address[[[,do_tcp], so_reuseport], tcp_fast_open_qsize])
93
94 .. deprecated:: 1.2.0
95
96 Add to the list of addresses listened on.
97
98 :param str address: The IP Address with an optional port to listen on.
99 The default port is 53.
100 :param bool do_tcp: Also bind a TCP port on ``address``, defaults to true.
101 :param bool so_reuseport: Use ``SO_REUSEPORT`` if it is available, defaults to false
102 :param int tcp_fast_open_qsize: The size of the TCP Fast Open queue. Set to a number
103 higher than 0 to enable TCP Fast Open when available.
104 Default is 0.
105
106 .. function:: addDOHLocal(address, [certFile(s) [, keyFile(s) [, urls [, options]]]])
107
108 .. versionadded:: 1.4.0
109
110 Listen on the specified address and TCP port for incoming DNS over HTTPS connections, presenting the specified X.509 certificate.
111 If no certificate (or key) files are specified, listen for incoming DNS over HTTP connections instead.
112
113 :param str address: The IP Address with an optional port to listen on.
114 The default port is 443.
115 :param str certFile(s): The path to a X.509 certificate file in PEM format, or a list of paths to such files.
116 :param str keyFile(s): The path to the private key file corresponding to the certificate, or a list of paths to such files, whose order should match the certFile(s) ones.
117 :param str-or-list urls: A base URL, or a list of base URLs, to accept queries on. Any query with a path under one of these will be treated as a DoH query. The default is /.
118 :param table options: A table with key: value pairs with listen options.
119
120 Options:
121
122 * ``reusePort=false``: bool - Set the ``SO_REUSEPORT`` socket option.
123 * ``tcpFastOpenQueueSize=0``: int - Set the TCP Fast Open queue size, enabling TCP Fast Open when available and the value is larger than 0.
124 * ``interface=""``: str - Set the network interface to use.
125 * ``cpus={}``: table - Set the CPU affinity for this listener thread, asking the scheduler to run it on a single CPU id, or a set of CPU ids. This parameter is only available if the OS provides the pthread_setaffinity_np() function.
126 * ``idleTimeout=30``: int - Set the idle timeout, in seconds.
127 * ``ciphers``: str - The TLS ciphers to use, in OpenSSL format. Ciphers for TLS 1.3 must be specified via ``ciphersTLS13``.
128 * ``ciphersTLS13``: str - The TLS ciphers to use for TLS 1.3, in OpenSSL format.
129 * ``serverTokens``: str - The content of the Server: HTTP header returned by dnsdist. The default is "h2o/dnsdist".
130 * ``customResponseHeaders={}``: table - Set custom HTTP header(s) returned by dnsdist.
131 * ``ocspResponses``: list - List of files containing OCSP responses, in the same order than the certificates and keys, that will be used to provide OCSP stapling responses.
132 * ``minTLSVersion``: str - Minimum version of the TLS protocol to support. Possible values are 'tls1.0', 'tls1.1', 'tls1.2' and 'tls1.3'. Default is to require at least TLS 1.0.
133 * ``numberOfTicketsKeys``: int - The maximum number of tickets keys to keep in memory at the same time. Only one key is marked as active and used to encrypt new tickets while the remaining ones can still be used to decrypt existing tickets after a rotation. Default to 5.
134 * ``ticketKeyFile``: str - The path to a file from where TLS tickets keys should be loaded, to support RFC 5077. These keys should be rotated often and never written to persistent storage to preserve forward secrecy. The default is to generate a random key. dnsdist supports several tickets keys to be able to decrypt existing sessions after the rotation.
135 * ``ticketsKeysRotationDelay``: int - Set the delay before the TLS tickets key is rotated, in seconds. Default is 43200 (12h).
136 * ``sessionTickets``: bool - Whether session resumption via session tickets is enabled. Default is true, meaning tickets are enabled.
137 * ``numberOfStoredSessions``: int - The maximum number of sessions kept in memory at the same time. Default is 20480. Setting this value to 0 disables stored session entirely.
138 * ``preferServerCiphers``: bool - Whether to prefer the order of ciphers set by the server instead of the one set by the client. Default is false, meaning that the order of the client is used.
139
140 .. function:: addTLSLocal(address, certFile(s), keyFile(s) [, options])
141
142 .. versionadded:: 1.3.0
143 .. versionchanged:: 1.3.1
144 ``certFile(s)`` and ``keyFile(s)`` parameters accept a list of files.
145 ``sessionTickets`` option added.
146 .. versionchanged:: 1.3.3
147 ``numberOfStoredSessions`` option added.
148 .. versionchanged:: 1.4.0
149 ``ciphersTLS13``, ``minTLSVersion``, ``ocspResponses`` and ``preferServerCiphers`` options added.
150
151 Listen on the specified address and TCP port for incoming DNS over TLS connections, presenting the specified X.509 certificate.
152
153 :param str address: The IP Address with an optional port to listen on.
154 The default port is 853.
155 :param str certFile(s): The path to a X.509 certificate file in PEM format, or a list of paths to such files.
156 :param str keyFile(s): The path to the private key file corresponding to the certificate, or a list of paths to such files, whose order should match the certFile(s) ones.
157 :param table options: A table with key: value pairs with listen options.
158
159 Options:
160
161 * ``reusePort=false``: bool - Set the ``SO_REUSEPORT`` socket option.
162 * ``tcpFastOpenQueueSize=0``: int - Set the TCP Fast Open queue size, enabling TCP Fast Open when available and the value is larger than 0.
163 * ``interface=""``: str - Set the network interface to use.
164 * ``cpus={}``: table - Set the CPU affinity for this listener thread, asking the scheduler to run it on a single CPU id, or a set of CPU ids. This parameter is only available if the OS provides the pthread_setaffinity_np() function.
165 * ``provider``: str - The TLS library to use between GnuTLS and OpenSSL, if they were available and enabled at compilation time.
166 * ``ciphers``: str - The TLS ciphers to use. The exact format depends on the provider used. When the OpenSSL provder is used, ciphers for TLS 1.3 must be specified via ``ciphersTLS13``.
167 * ``ciphersTLS13``: str - The ciphers to use for TLS 1.3, when the OpenSSL provider is used. When the GnuTLS provider is used, ``ciphers`` applies regardless of the TLS protocol and this setting is not used.
168 * ``numberOfTicketsKeys``: int - The maximum number of tickets keys to keep in memory at the same time, if the provider supports it (GnuTLS doesn't, OpenSSL does). Only one key is marked as active and used to encrypt new tickets while the remaining ones can still be used to decrypt existing tickets after a rotation. Default to 5.
169 * ``ticketKeyFile``: str - The path to a file from where TLS tickets keys should be loaded, to support RFC 5077. These keys should be rotated often and never written to persistent storage to preserve forward secrecy. The default is to generate a random key. The OpenSSL provider supports several tickets keys to be able to decrypt existing sessions after the rotation, while the GnuTLS provider only supports one key.
170 * ``ticketsKeysRotationDelay``: int - Set the delay before the TLS tickets key is rotated, in seconds. Default is 43200 (12h).
171 * ``sessionTickets``: bool - Whether session resumption via session tickets is enabled. Default is true, meaning tickets are enabled.
172 * ``numberOfStoredSessions``: int - The maximum number of sessions kept in memory at the same time. At this time this is only supported by the OpenSSL provider, as stored sessions are not supported with the GnuTLS one. Default is 20480. Setting this value to 0 disables stored session entirely.
173 * ``ocspResponses``: list - List of files containing OCSP responses, in the same order than the certificates and keys, that will be used to provide OCSP stapling responses.
174 * ``minTLSVersion``: str - Minimum version of the TLS protocol to support. Possible values are 'tls1.0', 'tls1.1', 'tls1.2' and 'tls1.3'. Default is to require at least TLS 1.0. Note that this value is ignored when the GnuTLS provider is in use, and the ``ciphers`` option should be set accordingly instead. For example, 'NORMAL:!VERS-TLS1.0:!VERS-TLS1.1' will disable TLS 1.0 and 1.1.
175 * ``preferServerCiphers``: bool - Whether to prefer the order of ciphers set by the server instead of the one set by the client. Default is false, meaning that the order of the client is used.
176
177 .. function:: setLocal(address[, options])
178
179 .. versionadded:: 1.2.0
180
181 Remove the list of listen addresses and add a new one.
182
183 :param str address: The IP Address with an optional port to listen on.
184 The default port is 53.
185 :param table options: A table with key: value pairs with listen options.
186
187 The options that can be set are the same as :func:`addLocal`.
188
189 .. function:: setLocal(address[[[,do_tcp], so_reuseport], tcp_fast_open_qsize])
190
191 .. deprecated:: 1.2.0
192
193 Remove the list of listen addresses and add a new one.
194
195 :param str address: The IP Address with an optional port to listen on.
196 The default port is 53.
197 :param bool do_tcp: Also bind a TCP port on ``address``, defaults to true.
198 :param bool so_reuseport: Use ``SO_REUSEPORT`` if it is available, defaults to false
199 :param int tcp_fast_open_qsize: The size of the TCP Fast Open queue. Set to a number
200 higher than 0 to enable TCP Fast Open when available.
201 Default is 0.
202
203 Control Socket, Console and Webserver
204 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
205
206 .. function:: addConsoleACL(netmask)
207
208 .. versionadded:: 1.3.0
209
210 Add a netmask to the existing console ACL, allowing remote clients to connect to the console. Please make sure that encryption
211 has been enabled with :func:`setKey` before doing so. The default is to only allow 127.0.0.1/8 and ::1/128.
212
213 :param str netmask: A CIDR netmask, e.g. ``"192.0.2.0/24"``. Without a subnetmask, only the specific address is allowed.
214
215 .. function:: controlSocket(address)
216
217 Bind to ``addr`` and listen for a connection for the console. Since 1.3.0 only connections from local users are allowed
218 by default, :func:`addConsoleACL` and :func:`setConsoleACL` can be used to enable remote connections. Please make sure
219 that encryption has been enabled with :func:`setKey` before doing so. Enabling encryption is also strongly advised for
220 local connections, since not enabling it allows any local user to connect to the console.
221
222 :param str address: An IP address with optional port. By default, the port is 5199.
223
224 .. function:: inClientStartup()
225
226 Returns true while the console client is parsing the configuration.
227
228 .. function:: makeKey()
229
230 Generate and print an encryption key.
231
232 .. function:: setConsoleConnectionsLogging(enabled)
233
234 .. versionadded:: 1.2.0
235
236 Whether to log the opening and closing of console connections.
237
238 :param bool enabled: Default to true.
239
240 .. function:: setKey(key)
241
242 Use ``key`` as shared secret between the client and the server
243
244 :param str key: An encoded key, as generated by :func:`makeKey`
245
246 .. function:: setConsoleACL(netmasks)
247
248 .. versionadded:: 1.3.0
249
250 Remove the existing console ACL and add the netmasks from the table, allowing remote clients to connect to the console. Please make sure that encryption
251 has been enabled with :func:`setKey` before doing so.
252
253 :param {str} netmasks: A table of CIDR netmask, e.g. ``{"192.0.2.0/24", "2001:DB8:14::/56"}``. Without a subnetmask, only the specific address is allowed.
254
255 .. function:: showConsoleACL()
256
257 Print a list of all netmasks allowed to connect to the console.
258
259 .. function:: testCrypto()
260
261 Test the crypto code, will report errors when something is not ok.
262
263 .. function:: setConsoleOutputMaxMsgSize(size)
264
265 .. versionadded:: 1.3.3
266
267 Set the maximum size in bytes of a single console message, default set to 10 MB.
268
269 :param int size: The new maximum size.
270
271 Webserver configuration
272 ~~~~~~~~~~~~~~~~~~~~~~~
273
274 .. function:: webserver(listen_address, password[, apikey[, custom_headers]])
275
276 Launch the :doc:`../guides/webserver` with statistics and the API.
277
278 :param str listen_address: The IP address and Port to listen on
279 :param str password: The password required to access the webserver
280 :param str apikey: The key required to access the API
281 :param {[str]=str,...} custom_headers: Allows setting custom headers and removing the defaults
282
283 .. function:: setAPIWritable(allow [,dir])
284
285 Allow modifications via the API.
286 Optionally saving these changes to disk.
287 Modifications done via the API will not be written to the configuration by default and will not persist after a reload
288
289 :param bool allow: Set to true to allow modification through the API
290 :param str dir: A valid directory where the configuration files will be written by the API.
291
292 .. function:: setWebserverConfig(options)
293
294 .. versionadded:: 1.3.3
295
296 Setup webserver configuration. See :func:`webserver`.
297
298 :param table options: A table with key: value pairs with webserver options.
299
300 Options:
301
302 * ``password=newPassword``: string - Changes the API password
303 * ``apikey=newKey``: string - Changes the API Key (set to an empty string do disable it)
304 * ``custom_headers={[str]=str,...}``: map of string - Allows setting custom headers and removing the defaults.
305
306 Access Control Lists
307 ~~~~~~~~~~~~~~~~~~~~
308
309 .. function:: addACL(netmask)
310
311 Add a netmask to the existing ACL controlling which clients can send UDP, TCP, DNS over TLS and DNS over HTTPS queries. See :ref:`ACL` for more information.
312
313 :param str netmask: A CIDR netmask, e.g. ``"192.0.2.0/24"``. Without a subnetmask, only the specific address is allowed.
314
315 .. function:: setACL(netmasks)
316
317 Remove the existing ACL and add the netmasks from the table of those allowed to send UDP, TCP, DNS over TLS and DNS over HTTPS queries. See :ref:`ACL` for more information.
318
319 :param {str} netmasks: A table of CIDR netmask, e.g. ``{"192.0.2.0/24", "2001:DB8:14::/56"}``. Without a subnetmask, only the specific address is allowed.
320
321 .. function:: showACL()
322
323 Print a list of all netmasks allowed to send queries over UDP, TCP, DNS over TLS and DNS over HTTPS. See :ref:`ACL` for more information.
324
325 EDNS Client Subnet
326 ~~~~~~~~~~~~~~~~~~
327
328 .. function:: setECSOverride(bool)
329
330 When ``useClientSubnet`` in :func:`newServer` is set and dnsdist adds an EDNS Client Subnet Client option to the query, override an existing option already present in the query, if any
331
332 :param bool: Whether to override an existing EDNS Client Subnet option present in the query. Defaults to false
333
334 .. function:: setECSSourcePrefixV4(prefix)
335
336 When ``useClientSubnet`` in :func:`newServer` is set and dnsdist adds an EDNS Client Subnet Client option to the query, truncate the requestors IPv4 address to ``prefix`` bits
337
338 :param int prefix: The prefix length
339
340 .. function:: setECSSourcePrefixV6(prefix)
341
342 When ``useClientSubnet`` in :func:`newServer` is set and dnsdist adds an EDNS Client Subnet Client option to the query, truncate the requestor's IPv6 address to bits
343
344 :param int prefix: The prefix length
345
346 Ringbuffers
347 ~~~~~~~~~~~
348
349 .. function:: setRingBuffersLockRetries(num)
350
351 .. versionadded:: 1.3.0
352
353 Set the number of shards to attempt to lock without blocking before giving up and simply blocking while waiting for the next shard to be available
354
355 :param int num: The maximum number of attempts. Defaults to 5 if there is more than one shard, 0 otherwise.
356
357 .. function:: setRingBuffersSize(num [, numberOfShards])
358
359 .. versionchanged:: 1.3.0
360 ``numberOfShards`` optional parameter added.
361
362 Set the capacity of the ringbuffers used for live traffic inspection to ``num``, and the number of shards to ``numberOfShards`` if specified.
363
364 :param int num: The maximum amount of queries to keep in the ringbuffer. Defaults to 10000
365 :param int numberOfShards: the number of shards to use to limit lock contention. Defaults to 1
366
367 Servers
368 -------
369
370 .. function:: newServer(server_string)
371 newServer(server_table)
372
373 .. versionchanged:: 1.3.0
374 Added ``checkClass``, ``sockets`` and ``checkFunction`` to server_table.
375
376 .. versionchanged:: 1.4.0
377 Added ``checkInterval``, ``checkTimeout`` and ``rise`` to server_table.
378
379 Add a new backend server. Call this function with either a string::
380
381 newServer(
382 "IP:PORT" -- IP and PORT of the backend server
383 )
384
385 or a table::
386
387 newServer({
388 address="IP:PORT", -- IP and PORT of the backend server (mandatory)
389 id=STRING, -- Use a pre-defined UUID instead of a random one
390 qps=NUM, -- Limit the number of queries per second to NUM, when using the `firstAvailable` policy
391 order=NUM, -- The order of this server, used by the `leastOutstanding` and `firstAvailable` policies
392 weight=NUM, -- The weight of this server, used by the `wrandom`, `whashed` and `chashed` policies, default: 1
393 -- Supported values are a minimum of 1, and a maximum of 2147483647.
394 pool=STRING|{STRING}, -- The pools this server belongs to (unset or empty string means default pool) as a string or table of strings
395 retries=NUM, -- The number of TCP connection attempts to the backend, for a given query
396 tcpConnectTimeout=NUM, -- The timeout (in seconds) of a TCP connection attempt
397 tcpSendTimeout=NUM, -- The timeout (in seconds) of a TCP write attempt
398 tcpRecvTimeout=NUM, -- The timeout (in seconds) of a TCP read attempt
399 tcpFastOpen=BOOL, -- Whether to enable TCP Fast Open
400 ipBindAddrNoPort=BOOL, -- Whether to enable IP_BIND_ADDRESS_NO_PORT if available, default: true
401 name=STRING, -- The name associated to this backend, for display purpose
402 checkClass=NUM, -- Use NUM as QCLASS in the health-check query, default: DNSClass.IN
403 checkName=STRING, -- Use STRING as QNAME in the health-check query, default: "a.root-servers.net."
404 checkType=STRING, -- Use STRING as QTYPE in the health-check query, default: "A"
405 checkFunction=FUNCTION,-- Use this function to dynamically set the QNAME, QTYPE and QCLASS to use in the health-check query (see :ref:`Healthcheck`)
406 checkTimeout=NUM, -- The timeout (in milliseconds) of a health-check query, default: 1000 (1s)
407 setCD=BOOL, -- Set the CD (Checking Disabled) flag in the health-check query, default: false
408 maxCheckFailures=NUM, -- Allow NUM check failures before declaring the backend down, default: 1
409 checkInterval=NUM -- The time in seconds between health checks
410 mustResolve=BOOL, -- Set to true when the health check MUST return a RCODE different from NXDomain, ServFail and Refused. Default is false, meaning that every RCODE except ServFail is considered valid
411 useClientSubnet=BOOL, -- Add the client's IP address in the EDNS Client Subnet option when forwarding the query to this backend
412 source=STRING, -- The source address or interface to use for queries to this backend, by default this is left to the kernel's address selection
413 -- The following formats are supported:
414 -- "address", e.g. "192.0.2.2"
415 -- "interface name", e.g. "eth0"
416 -- "address@interface", e.g. "192.0.2.2@eth0"
417 addXPF=NUM, -- Add the client's IP address and port to the query, along with the original destination address and port,
418 -- using the experimental XPF record from `draft-bellis-dnsop-xpf <https://datatracker.ietf.org/doc/draft-bellis-dnsop-xpf/>`_ and the specified option code. Default is disabled (0)
419 sockets=NUM, -- Number of sockets (and thus source ports) used toward the backend server, defaults to a single one
420 disableZeroScope=BOOL, -- Disable the EDNS Client Subnet 'zero scope' feature, which does a cache lookup for an answer valid for all subnets (ECS scope of 0) before adding ECS information to the query and doing the regular lookup
421 rise=NUM -- Require NUM consecutive successful checks before declaring the backend up, default: 1
422 })
423
424 :param str server_string: A simple IP:PORT string.
425 :param table server_table: A table with at least a 'name' key
426
427 .. function:: getServer(index) -> Server
428
429 Get a :class:`Server`
430
431 :param int index: The number of the server (as seen in :func:`showServers`).
432 :returns: The :class:`Server` object or nil
433
434 .. function:: getServers()
435
436 Returns a table with all defined servers.
437
438 .. function:: rmServer(index)
439 rmServer(server)
440
441 Remove a backend server.
442
443 :param int index: The number of the server (as seen in :func:`showServers`).
444 :param Server server: A :class:`Server` object as returned by e.g. :func:`getServer`.
445
446 Server Functions
447 ~~~~~~~~~~~~~~~~
448 A server object returned by :func:`getServer` can be manipulated with these functions.
449
450 .. class:: Server
451
452 This object represents a backend server. It has several methods.
453
454 .. method:: Server:addPool(pool)
455
456 Add this server to a pool.
457
458 :param str pool: The pool to add the server to
459
460 .. method:: Server:getName() -> string
461
462 Get the name of this server.
463
464 :returns: The name of the server, or an empty string if it does not have one
465
466 .. method:: Server:getNameWithAddr() -> string
467
468 Get the name plus IP address and port of the server
469
470 :returns: A string containing the server name if any plus the server address and port
471
472 .. method:: Server:getOutstanding() -> int
473
474 Get the number of outstanding queries for this server.
475
476 :returns: The number of outstanding queries
477
478 .. method:: Server:isUp() -> bool
479
480 Returns the up status of the server
481
482 :returns: true when the server is up, false otherwise
483
484 .. method:: Server:rmPool(pool)
485
486 Removes the server from the named pool
487
488 :param str pool: The pool to remove the server from
489
490 .. method:: Server:setAuto([status])
491
492 .. versionchanged:: 1.3.0
493 ``status`` optional parameter added.
494
495 Set the server in the default auto state.
496 This will enable health check queries that will set the server ``up`` and ``down`` appropriately.
497
498 :param bool status: Set the initial status of the server to ``up`` (true) or ``down`` (false) instead of using the last known status
499
500 .. method:: Server:setQPS(limit)
501
502 Limit the queries per second for this server.
503
504 :param int limit: The maximum number of queries per second
505
506 .. method:: Server:setDown()
507
508 Set the server in an ``DOWN`` state.
509 The server will not receive queries and the health checks are disabled
510
511 .. method:: Server:setUp()
512
513 Set the server in an ``UP`` state.
514 This server will still receive queries and health checks are disabled
515
516 Apart from the functions, a :class:`Server` object has these attributes:
517
518 .. attribute:: Server.name
519
520 The name of the server
521
522 .. attribute:: Server.upStatus
523
524 Whether or not this server is up or down
525
526 .. attribute:: Server.order
527
528 The order of the server
529
530 .. attribute:: Server.weight
531
532 The weight of the server
533
534 Pools
535 -----
536
537 :class:`Server`\ s can be part of any number of pools.
538 Pools are automatically created when a server is added to a pool (with :func:`newServer`), or can be manually created with :func:`addPool`.
539
540 .. function:: addPool(name) -> ServerPool
541
542 Returns a :class:`ServerPool`.
543
544 :param string name: The name of the pool to create
545
546 .. function:: getPool(name) -> ServerPool
547
548 Returns a :class:`ServerPool` or nil.
549
550 :param string name: The name of the pool
551
552 .. function:: getPoolServers(name) -> [ Server ]
553
554 Returns a list of :class:`Server`\ s or nil.
555
556 :param string name: The name of the pool
557
558 .. function:: showPools()
559
560 Display the name, associated cache, server policy and associated servers for every pool.
561
562 .. class:: ServerPool
563
564 This represents the pool where zero or more servers are part of.
565
566 .. method:: ServerPool:getCache() -> PacketCache
567
568 Returns the :class:`PacketCache` for this pool or nil.
569
570 .. method:: ServerPool:getECS()
571
572 .. versionadded:: 1.3.0
573
574 Whether dnsdist will add EDNS Client Subnet information to the query before looking up into the cache,
575 when all servers from this pool are down. For more information see :meth:`ServerPool:setECS`.
576
577 .. method:: ServerPool:setCache(cache)
578
579 Adds ``cache`` as the pool's cache.
580
581 :param PacketCache cache: The new cache to add to the pool
582
583 .. method:: ServerPool:unsetCache()
584
585 Removes the cache from this pool.
586
587 .. method:: ServerPool:setECS()
588
589 .. versionadded:: 1.3.0
590
591 Set to true if dnsdist should add EDNS Client Subnet information to the query before looking up into the cache,
592 when all servers from this pool are down. If at least one server is up, the preference of the
593 selected server is used, this parameter is only useful if all the backends in this pool are down
594 and have EDNS Client Subnet enabled, since the queries in the cache will have been inserted with
595 ECS information. Default is false.
596
597 PacketCache
598 ~~~~~~~~~~~
599
600 A Pool can have a packet cache to answer queries directly instead of going to the backend.
601 See :doc:`../guides/cache` for a how to.
602
603 .. function:: newPacketCache(maxEntries[, maxTTL=86400[, minTTL=0[, temporaryFailureTTL=60[, staleTTL=60[, dontAge=false[, numberOfShards=1[, deferrableInsertLock=true[, maxNegativeTTL=3600[, parseECS=false]]]]]]]) -> PacketCache
604
605 .. versionchanged:: 1.3.0
606 ``numberOfShards`` and ``deferrableInsertLock`` parameters added.
607
608 .. versionchanged:: 1.3.1
609 ``maxNegativeTTL`` and ``parseECS`` parameters added.
610
611 .. deprecated:: 1.4.0
612
613 Creates a new :class:`PacketCache` with the settings specified.
614
615 :param int maxEntries: The maximum number of entries in this cache
616 :param int maxTTL: Cap the TTL for records to his number
617 :param int minTTL: Don't cache entries with a TTL lower than this
618 :param int temporaryFailureTTL: On a SERVFAIL or REFUSED from the backend, cache for this amount of seconds
619 :param int staleTTL: When the backend servers are not reachable, and global configuration ``setStaleCacheEntriesTTL`` is set appropriately, TTL that will be used when a stale cache entry is returned
620 :param bool dontAge: Don't reduce TTLs when serving from the cache. Use this when :program:`dnsdist` fronts a cluster of authoritative servers
621 :param int numberOfShards: Number of shards to divide the cache into, to reduce lock contention
622 :param bool deferrableInsertLock: Whether the cache should give up insertion if the lock is held by another thread, or simply wait to get the lock
623 :param int maxNegativeTTL: Cache a NXDomain or NoData answer from the backend for at most this amount of seconds, even if the TTL of the SOA record is higher
624 :param bool parseECS: Whether any EDNS Client Subnet option present in the query should be extracted and stored to be able to detect hash collisions involving queries with the same qname, qtype and qclass but a different incoming ECS value. Enabling this option adds a parsing cost and only makes sense if at least one backend might send different responses based on the ECS value, so it's disabled by default
625
626 .. function:: newPacketCache(maxEntries, [options]) -> PacketCache
627
628 .. versionadded:: 1.4.0
629
630 Creates a new :class:`PacketCache` with the settings specified.
631
632 :param int maxEntries: The maximum number of entries in this cache
633
634 Options:
635
636 * ``deferrableInsertLock=true``: bool - Whether the cache should give up insertion if the lock is held by another thread, or simply wait to get the lock.
637 * ``dontAge=false``: bool - Don't reduce TTLs when serving from the cache. Use this when :program:`dnsdist` fronts a cluster of authoritative servers.
638 * ``keepStaleData=false``: bool - Whether to suspend the removal of expired entries from the cache when there is no backend available in at least one of the pools using this cache.
639 * ``maxNegativeTTL=3600``: int - Cache a NXDomain or NoData answer from the backend for at most this amount of seconds, even if the TTL of the SOA record is higher.
640 * ``maxTTL=86400``: int - Cap the TTL for records to his number.
641 * ``minTTL=0``: int - Don't cache entries with a TTL lower than this.
642 * ``numberOfShards=1``: int - Number of shards to divide the cache into, to reduce lock contention.
643 * ``parseECS=false``: bool - Whether any EDNS Client Subnet option present in the query should be extracted and stored to be able to detect hash collisions involving queries with the same qname, qtype and qclass but a different incoming ECS value. Enabling this option adds a parsing cost and only makes sense if at least one backend might send different responses based on the ECS value, so it's disabled by default.
644 * ``staleTTL=60``: int - When the backend servers are not reachable, and global configuration ``setStaleCacheEntriesTTL`` is set appropriately, TTL that will be used when a stale cache entry is returned.
645 * ``temporaryFailureTTL=60``: int - On a SERVFAIL or REFUSED from the backend, cache for this amount of seconds..
646
647 .. class:: PacketCache
648
649 Represents a cache that can be part of :class:`ServerPool`.
650
651 .. method:: PacketCache:dump(fname)
652
653 .. versionadded:: 1.3.1
654
655 Dump a summary of the cache entries to a file.
656
657 :param str fname: The path to a file where the cache summary should be dumped. Note that if the target file already exists, it will not be overwritten.
658
659 .. method:: PacketCache:expunge(n)
660
661 Remove entries from the cache, leaving at most ``n`` entries
662
663 :param int n: Number of entries to keep
664
665 .. method:: PacketCache:expungeByName(name [, qtype=DNSQType.ANY[, suffixMatch=false]])
666
667 .. versionchanged:: 1.2.0
668 ``suffixMatch`` parameter added.
669
670 Remove entries matching ``name`` and type from the cache.
671
672 :param DNSName name: The name to expunge
673 :param int qtype: The type to expunge, can be a pre-defined :ref:`DNSQType`
674 :param bool suffixMatch: When set to true, remove al entries under ``name``
675
676 .. method:: PacketCache:getStats()
677
678 .. versionadded:: 1.4.0
679
680 Return the cache stats (number of entries, hits, misses, deferred lookups, deferred inserts, lookup collisions, insert collisions and TTL too shorts) as a Lua table.
681
682 .. method:: PacketCache:isFull() -> bool
683
684 Return true if the cache has reached the maximum number of entries.
685
686 .. method:: PacketCache:printStats()
687
688 Print the cache stats (number of entries, hits, misses, deferred lookups, deferred inserts, lookup collisions, insert collisions and TTL too shorts).
689
690 .. method:: PacketCache:purgeExpired(n)
691
692 Remove expired entries from the cache until there is at most ``n`` entries remaining in the cache.
693
694 :param int n: Number of entries to keep
695
696 .. method:: PacketCache:toString() -> string
697
698 Return the number of entries in the Packet Cache, and the maximum number of entries
699
700 Client State
701 ------------
702
703 Also called frontend or bind, the Client State object returned by :func:`getBind` and listed with :func:`showBinds` represents an address and port dnsdist is listening on.
704
705 .. function:: getBind(index) -> ClientState
706
707 Return a :class:`ClientState` object.
708
709 :param int index: The object index
710
711 ClientState functions
712 ~~~~~~~~~~~~~~~~~~~~~
713
714 .. class:: ClientState
715
716 This object represents an address and port dnsdist is listening on. When ``reuseport`` is in use, several ClientState objects can be present for the same address and port.
717
718 .. method:: ClientState:attachFilter(filter)
719
720 Attach a BPF filter to this frontend.
721
722 :param BPFFilter filter: The filter to attach to this frontend
723
724 .. method:: ClientState:detachFilter()
725
726 Remove the BPF filter associated to this frontend, if any.
727
728 .. method:: ClientState:toString() -> string
729
730 Return the address and port this frontend is listening on.
731
732 :returns: The address and port this frontend is listening on
733
734 .. attribute:: ClientState.muted
735
736 If set to true, queries received on this frontend will be normally processed and sent to a backend if needed, but no response will be ever be sent to the client over UDP. TCP queries are processed normally and responses sent to the client.
737
738 Status, Statistics and More
739 ---------------------------
740
741 .. function:: dumpStats()
742
743 Print all statistics dnsdist gathers
744
745 .. function:: getDOHFrontend(idx)
746
747 .. versionadded:: 1.4.0
748
749 Return the DOHFrontend object for the DNS over HTTPS bind of index ``idx``.
750
751 .. function:: getTLSContext(idx)
752
753 .. versionadded:: 1.3.0
754
755 Return the TLSContext object for the context of index ``idx``.
756
757 .. function:: getTLSFrontend(idx)
758
759 .. versionadded:: 1.3.1
760
761 Return the TLSFrontend object for the TLS bind of index ``idx``.
762
763 .. function:: grepq(selector[, num])
764 grepq(selectors[, num])
765
766 Prints the last ``num`` queries matching ``selector`` or ``selectors``.
767
768 The selector can be:
769
770 * a netmask (e.g. '192.0.2.0/24')
771 * a DNS name (e.g. 'dnsdist.org')
772 * a response time (e.g. '100ms')
773
774 :param str selector: Select queries based on this property.
775 :param {str} selectors: A lua table of selectors. Only queries matching all selectors are shown
776 :param int num: Show a maximum of ``num`` recent queries, default is 10.
777
778 .. function:: setVerboseHealthChecks(verbose)
779
780 Set whether health check errors should be logged. This is turned off by default.
781
782 :param bool verbose: Set to true if you want to enable health check errors logging
783
784 .. function:: showBinds()
785
786 Print a list of all the current addresses and ports dnsdist is listening on, also called ``frontends``
787
788 .. function:: showDOHFrontends()
789
790 .. versionadded:: 1.4.0
791
792 Print the list of all availables DNS over HTTPS frontends.
793
794 .. function:: showDOHResponseCodes()
795
796 .. versionadded:: 1.4.0
797
798 Print the HTTP response codes statistics for all availables DNS over HTTPS frontends.
799
800 .. function:: showResponseLatency()
801
802 Show a plot of the response time latency distribution
803
804 .. function:: showServers([options])
805
806 .. versionchanged:: 1.4.0
807 ``options`` optional parameter added
808
809 This function shows all backend servers currently configured and some statistics.
810 These statics have the following fields:
811
812 * ``#`` - The number of the server, can be used as the argument for :func:`getServer`
813 * ``UUID`` - The UUID of the backend. Can be set with the ``id`` option of :func:`newServer`
814 * ``Address`` - The IP address and port of the server
815 * ``State`` - The current state of the server
816 * ``Qps`` - Current number of queries per second
817 * ``Qlim`` - Configured maximum number of queries per second
818 * ``Ord`` - The order number of the server
819 * ``Wt`` - The weight of the server
820 * ``Queries`` - Total amount of queries sent to this server
821 * ``Drops`` - Number of queries that were dropped by this server
822 * ``Drate`` - Number of queries dropped per second by this server
823 * ``Lat`` - The latency of this server in milliseconds
824 * ``Pools`` - The pools this server belongs to
825
826 :param table options: A table with key: value pairs with display options.
827
828 Options:
829
830 * ``showUUIDs=false``: bool - Whether to display the UUIDs, defaults to false.
831
832 .. function:: showTCPStats()
833
834 Show some statistics regarding TCP
835
836 .. function:: showTLSContexts()
837
838 .. versionadded:: 1.3.0
839
840 Print the list of all availables DNS over TLS contexts.
841
842 .. function:: showVersion()
843
844 Print the version of dnsdist
845
846 .. function:: topBandwidth([num])
847
848 Print the top ``num`` clients that consume the most bandwidth.
849
850 :param int num: Number to show, defaults to 10.
851
852 .. function:: topClients([num])
853
854 Print the top ``num`` clients sending the most queries over length of ringbuffer
855
856 :param int num: Number to show, defaults to 10.
857
858 .. function:: topQueries([num[, labels]])
859
860 Print the ``num`` most popular QNAMEs from queries.
861 Optionally grouped by the rightmost ``labels`` DNS labels.
862
863 :param int num: Number to show, defaults to 10
864 :param int label: Number of labels to cut down to
865
866 .. function:: topResponses([num[, rcode[, labels]]])
867
868 Print the ``num`` most seen responses with an RCODE of ``rcode``.
869 Optionally grouped by the rightmost ``labels`` DNS labels.
870
871 :param int num: Number to show, defaults to 10
872 :param int rcode: :ref:`Response code <DNSRCode>`, defaults to 0 (No Error)
873 :param int label: Number of labels to cut down to
874
875 .. function:: topSlow([num[, limit[, labels]]])
876
877 Print the ``num`` slowest queries that are slower than ``limit`` milliseconds.
878 Optionally grouped by the rightmost ``labels`` DNS labels.
879
880 :param int num: Number to show, defaults to 10
881 :param int limit: Show queries slower than this amount of milliseconds, defaults to 2000
882 :param int label: Number of labels to cut down to
883
884 .. _dynblocksref:
885
886 Dynamic Blocks
887 --------------
888
889 .. function:: addDynBlocks(addresses, message[, seconds=10[, action]])
890
891 .. versionchanged:: 1.2.0
892 ``action`` parameter added.
893
894 Block a set of addresses with ``message`` for (optionally) a number of seconds.
895 The default number of seconds to block for is 10.
896
897 :param addresses: set of Addresses as returned by an exceed function
898 :param string message: The message to show next to the blocks
899 :param int seconds: The number of seconds this block to expire
900 :param int action: The action to take when the dynamic block matches, see :ref:`here <DNSAction>`. (default to DNSAction.None, meaning the one set with :func:`setDynBlocksAction` is used)
901
902 Please see the documentation for :func:`setDynBlocksAction` to confirm which actions are supported by the action paramater.
903
904 .. function:: clearDynBlocks()
905
906 Remove all current dynamic blocks.
907
908 .. function:: showDynBlocks()
909
910 List all dynamic blocks in effect.
911
912 .. function:: setDynBlocksAction(action)
913
914 .. versionchanged:: 1.3.3
915 ``DNSAction.NXDomain`` action added.
916
917 Set which action is performed when a query is blocked.
918 Only DNSAction.Drop (the default), DNSAction.NoOp, DNSAction.NXDomain, DNSAction.Refused, DNSAction.Truncate and DNSAction.NoRecurse are supported.
919
920 .. _exceedfuncs:
921
922 Getting addresses that exceeded parameters
923 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
924
925 .. function:: exceedServFails(rate, seconds)
926
927 Get set of addresses that exceed ``rate`` servfails/s over ``seconds`` seconds
928
929 :param int rate: Number of Servfails per second to exceed
930 :param int seconds: Number of seconds the rate has been exceeded
931
932 .. function:: exceedNXDOMAINs(rate, seconds)
933
934 get set of addresses that exceed ``rate`` NXDOMAIN/s over ``seconds`` seconds
935
936 :param int rate: Number of NXDOMAIN per second to exceed
937 :param int seconds: Number of seconds the rate has been exceeded
938
939 .. function:: exceedRespByterate(rate, seconds)
940
941 get set of addresses that exceeded ``rate`` bytes/s answers over ``seconds`` seconds
942
943 :param int rate: Number of bytes per second to exceed
944 :param int seconds: Number of seconds the rate has been exceeded
945
946 .. function:: exceedQRate(rate, seconds)
947
948 Get set of address that exceed ``rate`` queries/s over ``seconds`` seconds
949
950 :param int rate: Number of queries per second to exceed
951 :param int seconds: Number of seconds the rate has been exceeded
952
953 .. function:: exceedQTypeRate(type, rate, seconds)
954
955 Get set of address that exceed ``rate`` queries/s for queries of QType ``type`` over ``seconds`` seconds
956
957 :param int type: QType
958 :param int rate: Number of QType queries per second to exceed
959 :param int seconds: Number of seconds the rate has been exceeded
960
961 DynBlockRulesGroup
962 ~~~~~~~~~~~~~~~~~~
963
964 Instead of using several `exceed*()` lines, dnsdist 1.3.0 introduced a new `DynBlockRulesGroup` object
965 which can be used to group dynamic block rules.
966
967 See :doc:`../guides/dynblocks` for more information about the case where using a `DynBlockRulesGroup` might be
968 faster than the existing rules.
969
970 .. function:: dynBlockRulesGroup() -> DynBlockRulesGroup
971
972 .. versionadded:: 1.3.0
973
974 Creates a new :class:`DynBlockRulesGroup` object.
975
976 .. class:: DynBlockRulesGroup
977
978 Represents a group of dynamic block rules.
979
980 .. method:: DynBlockRulesGroup:setQueryRate(rate, seconds, reason, blockingTime [, action [, warningRate]])
981
982 .. versionchanged:: 1.3.3
983 ``warningRate`` parameter added.
984
985 Adds a query rate-limiting rule, equivalent to:
986 ```
987 addDynBlocks(exceedQRate(rate, seconds), reason, blockingTime, action)
988 ```
989
990 :param int rate: Number of queries per second to exceed
991 :param int seconds: Number of seconds the rate has been exceeded
992 :param string reason: The message to show next to the blocks
993 :param int blockingTime: The number of seconds this block to expire
994 :param int action: The action to take when the dynamic block matches, see :ref:`here <DNSAction>`. (default to the one set with :func:`setDynBlocksAction`)
995 :param int warningRate: If set to a non-zero value, the rate above which a warning message will be issued and a no-op block inserted
996
997 .. method:: DynBlockRulesGroup:setRCodeRate(rcode, rate, seconds, reason, blockingTime [, action [, warningRate]])
998
999 .. versionchanged:: 1.3.3
1000 ``warningRate`` parameter added.
1001
1002 Adds a rate-limiting rule for responses of code ``rcode``, equivalent to:
1003 ```
1004 addDynBlocks(exceedServfails(rcode, rate, seconds), reason, blockingTime, action)
1005 ```
1006
1007 :param int rcode: The response code
1008 :param int rate: Number of responses per second to exceed
1009 :param int seconds: Number of seconds the rate has been exceeded
1010 :param string reason: The message to show next to the blocks
1011 :param int blockingTime: The number of seconds this block to expire
1012 :param int action: The action to take when the dynamic block matches, see :ref:`here <DNSAction>`. (default to the one set with :func:`setDynBlocksAction`)
1013 :param int warningRate: If set to a non-zero value, the rate above which a warning message will be issued and a no-op block inserted
1014
1015 .. method:: DynBlockRulesGroup:setQTypeRate(qtype, rate, seconds, reason, blockingTime [, action [, warningRate]])
1016
1017 .. versionchanged:: 1.3.3
1018 ``warningRate`` parameter added.
1019
1020 Adds a rate-limiting rule for queries of type ``qtype``, equivalent to:
1021 ```
1022 addDynBlocks(exceedQTypeRate(type, rate, seconds), reason, blockingTime, action)
1023 ```
1024
1025 :param int qtype: The qtype
1026 :param int rate: Number of queries per second to exceed
1027 :param int seconds: Number of seconds the rate has been exceeded
1028 :param string reason: The message to show next to the blocks
1029 :param int blockingTime: The number of seconds this block to expire
1030 :param int action: The action to take when the dynamic block matches, see :ref:`here <DNSAction>`. (default to the one set with :func:`setDynBlocksAction`)
1031 :param int warningRate: If set to a non-zero value, the rate above which a warning message will be issued and a no-op block inserted
1032
1033 .. method:: DynBlockRulesGroup:setResponseByteRate(rate, seconds, reason, blockingTime [, action [, warningRate]])
1034
1035 .. versionchanged:: 1.3.3
1036 ``warningRate`` parameter added.
1037
1038 Adds a bandwidth rate-limiting rule for responses, equivalent to:
1039 ```
1040 addDynBlocks(exceedRespByterate(rate, seconds), reason, blockingTime, action)
1041 ```
1042
1043 :param int rate: Number of bytes per second to exceed
1044 :param int seconds: Number of seconds the rate has been exceeded
1045 :param string reason: The message to show next to the blocks
1046 :param int blockingTime: The number of seconds this block to expire
1047 :param int action: The action to take when the dynamic block matches, see :ref:`here <DNSAction>`. (default to the one set with :func:`setDynBlocksAction`)
1048 :param int warningRate: If set to a non-zero value, the rate above which a warning message will be issued and a no-op block inserted
1049
1050 .. method:: DynBlockRulesGroup:apply()
1051
1052 Walk the in-memory query and response ring buffers and apply the configured rate-limiting rules, adding dynamic blocks when the limits have been exceeded.
1053
1054 .. method:: DynBlockRulesGroup:setQuiet(quiet)
1055
1056 .. versionadded:: 1.4.0
1057
1058 Set whether newly blocked clients or domains should be logged.
1059
1060 :param bool quiet: True means that insertions will not be logged, false that they will. Default is false.
1061
1062 .. method:: DynBlockRulesGroup:excludeRange(netmasks)
1063
1064 .. versionadded:: 1.3.1
1065
1066 Exclude this range, or list of ranges, meaning that no dynamic block will ever be inserted for clients in that range. Default to empty, meaning rules are applied to all ranges. When used in combination with :meth:`DynBlockRulesGroup:includeRange`, the more specific entry wins.
1067
1068 :param int netmasks: A netmask, or list of netmasks, as strings, like for example "192.0.2.1/24"
1069
1070 .. method:: DynBlockRulesGroup:includeRange(netmasks)
1071
1072 .. versionadded:: 1.3.1
1073
1074 Include this range, or list of ranges, meaning that rules will be applied to this range. When used in combination with :meth:`DynBlockRulesGroup:excludeRange`, the more specific entry wins.
1075
1076 :param int netmasks: A netmask, or list of netmasks, as strings, like for example "192.0.2.1/24"
1077
1078 .. method:: DynBlockRulesGroup:toString()
1079
1080 .. versionadded:: 1.3.1
1081
1082 Return a string describing the rules and range exclusions of this DynBlockRulesGroup.
1083
1084 SuffixMatchNode
1085 ~~~~~~~~~~~~~~~
1086
1087 A SuffixMatchNode can be used to quickly check whether a given name belongs to a set or not. This is achieved
1088 using an efficient tree structure based on DNS labels, making lookups cheap.
1089 Be careful that Suffix Node matching will match for any sub-domain, regardless of the depth, under the name added to the set. For example,
1090 if 'example.com.' is added to the set, 'www.example.com.' and 'sub.www.example.com.' will match as well.
1091 If you are looking for exact name matching, your might want to consider using a :class:`DNSNameSet` instead.
1092
1093 .. function:: newSuffixMatchNode()
1094
1095 Creates a new :class:`SuffixMatchNode`.
1096
1097 .. class:: SuffixMatchNode
1098
1099 Represent a set of DNS suffixes for quick matching.
1100
1101 .. method:: SuffixMatchNode:add(name)
1102
1103 .. versionchanged:: 1.4.0
1104 This method now accepts strings, lists of DNSNames and lists of strings.
1105
1106 Add a suffix to the current set.
1107
1108 :param DNSName name: The suffix to add to the set.
1109 :param string name: The suffix to add to the set.
1110 :param table name: The suffixes to add to the set. Elements of the table should be of the same type, either DNSName or string.
1111
1112 .. method:: SuffixMatchNode:check(name) -> bool
1113
1114 Return true if the given name is a sub-domain of one of those in the set, and false otherwise.
1115
1116 :param DNSName name: The name to test against the set.
1117
1118 Other functions
1119 ---------------
1120
1121 .. function:: maintenance()
1122
1123 If this function exists, it is called every second to so regular tasks.
1124 This can be used for e.g. :doc:`Dynamic Blocks <../guides/dynblocks>`.
1125
1126 .. function:: setAllowEmptyResponse()
1127
1128 .. versionadded:: 1.4.0
1129
1130 Set to true (defaults to false) to allow empty responses (qdcount=0) with a NoError or NXDomain rcode (default) from backends. dnsdist drops these responses by default because it can't match them against the initial query since they don't contain the qname, qtype and qclass, and therefore the risk of collision is much higher than with regular responses.
1131
1132 .. function:: makeIPCipherKey(password) -> string
1133
1134 .. versionadded:: 1.4.0
1135
1136 Hashes the password to generate a 16-byte key that can be used to pseudonymize IP addresses with IP cipher.
1137
1138 .. function:: generateOCSPResponse(pathToServerCertificate, pathToCACertificate, pathToCAPrivateKey, outputFile, numberOfDaysOfValidity, numberOfMinutesOfValidity)
1139
1140 .. versionadded:: 1.4.0
1141
1142 When a local PKI is used to issue the certificate, or for testing purposes, :func:`generateOCSPResponse` can be used to generate an OCSP response file for a certificate, using the certificate and private key of the certification authority that signed that certificate.
1143 The resulting file can be directly used with the :func:`addDOHLocal` or the :func:`addTLSLocal` functions.
1144
1145 :param string pathToServerCertificate: Path to a file containing the certificate used by the server.
1146 :param string pathToCACertificate: Path to a file containing the certificate of the certification authority that was used to sign the server certificate.
1147 :param string pathToCAPrivateKey: Path to a file containing the private key corresponding to the certification authority certificate.
1148 :param string outputFile: Path to a file where the resulting OCSP response will be written to.
1149 :param int numberOfDaysOfValidity: Number of days this OCSP response should be valid.
1150 :param int numberOfMinutesOfValidity: Number of minutes this OCSP response should be valid, in addition to the number of days.
1151
1152 DOHFrontend
1153 ~~~~~~~~~~~
1154
1155 .. class:: DOHFrontend
1156
1157 .. versionadded:: 1.4.0
1158
1159 This object represents an address and port dnsdist is listening on for DNS over HTTPS queries.
1160
1161 .. method:: DOHFrontend:loadTicketsKeys(ticketsKeysFile)
1162
1163 Load new tickets keys from the selected file, replacing the existing ones. These keys should be rotated often and never written to persistent storage to preserve forward secrecy. The default is to generate a random key. dnsdist supports several tickets keys to be able to decrypt existing sessions after the rotation.
1164
1165 :param str ticketsKeysFile: The path to a file from where TLS tickets keys should be loaded.
1166
1167 .. method:: DOHFrontend:reloadCertificates()
1168
1169 Reload the current TLS certificate and key pairs.
1170
1171 .. method:: DOHFrontend:rotateTicketsKey()
1172
1173 Replace the current TLS tickets key by a new random one.
1174
1175 .. method:: DOHFrontend:setResponsesMap(rules)
1176
1177 Set a list of HTTP response rules allowing to intercept HTTP queries very early, before the DNS payload has been processed, and send custom responses including error pages, redirects and static content.
1178
1179 :param list of DOHResponseMapEntry objects rules: A list of DOHResponseMapEntry objects, obtained with :func:`newDOHResponseMapEntry`.
1180
1181
1182 .. function:: newDOHResponseMapEntry(regex, status, content [, headers]) -> DOHResponseMapEntry
1183
1184 .. versionadded:: 1.4.0
1185
1186 Return a DOHResponseMapEntry that can be used with :meth:`DOHFrontend.setResponsesMap`. Every query whose path matches the regular expression supplied in ``regex`` will be immediately answered with a HTTP response.
1187 The status of the HTTP response will be the one supplied by ``status``, and the content set to the one supplied by ``content``, except if the status is a redirection (3xx) in which case the content is expected to be the URL to redirect to.
1188
1189 :param str regex: A regular expression to match the path against.
1190 :param int status: The HTTP code to answer with.
1191 :param str content: The content of the HTTP response, or a URL if the status is a redirection (3xx).
1192 :param table of headers: The custom headers to set for the HTTP response, if any. The default is to use the value of the ``customResponseHeaders`` parameter passed to :func:`addDOHLocal`.
1193
1194 TLSContext
1195 ~~~~~~~~~~
1196
1197 .. class:: TLSContext
1198
1199 .. versionadded:: 1.3.0
1200
1201 This object represents an address and port dnsdist is listening on for DNS over TLS queries.
1202
1203 .. method:: TLSContext:rotateTicketsKey()
1204
1205 Replace the current TLS tickets key by a new random one.
1206
1207 .. method:: TLSContext:loadTicketsKeys(ticketsKeysFile)
1208
1209 Load new tickets keys from the selected file, replacing the existing ones. These keys should be rotated often and never written to persistent storage to preserve forward secrecy. The default is to generate a random key. The OpenSSL provider supports several tickets keys to be able to decrypt existing sessions after the rotation, while the GnuTLS provider only supports one key.
1210
1211 :param str ticketsKeysFile: The path to a file from where TLS tickets keys should be loaded.
1212
1213 TLSFrontend
1214 ~~~~~~~~~~~
1215
1216 .. class:: TLSFrontend
1217
1218 .. versionadded:: 1.3.1
1219
1220 This object represents the configuration of a listening frontend for DNS over TLS queries. To each frontend is associated a TLSContext.
1221
1222 .. method:: TLSContext:loadNewCertificatesAndKeys(certFile(s), keyFile(s))
1223
1224 Create and switch to a new TLS context using the same options than were passed to the corresponding `addTLSLocal()` directive, but loading new certificates and keys from the selected files, replacing the existing ones.
1225
1226 :param str certFile(s): The path to a X.509 certificate file in PEM format, or a list of paths to such files.
1227 :param str keyFile(s): The path to the private key file corresponding to the certificate, or a list of paths to such files, whose order should match the certFile(s) ones.
1228
1229 EDNS on Self-generated answers
1230 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1231
1232 There are several mechanisms in dnsdist that turn an existing query into an answer right away,
1233 without reaching out to the backend, including :func:`SpoofAction`, :func:`RCodeAction`, :func:`TCAction`
1234 and returning a response from ``Lua``. Those responses should, according to :rfc:`6891`, contain an ``OPT``
1235 record if the received request had one, which is the case by default and can be disabled using
1236 :func:`setAddEDNSToSelfGeneratedResponses`.
1237
1238 We must, however, provide a responder's maximum payload size in this record, and we can't easily know the
1239 maximum payload size of the actual backend so we need to provide one. The default value is 1500 and can be
1240 overriden using :func:`setPayloadSizeOnSelfGeneratedAnswers`.
1241
1242 .. function:: setAddEDNSToSelfGeneratedResponses(add)
1243
1244 .. versionadded:: 1.3.3
1245
1246 Whether to add EDNS to self-generated responses, provided that the initial query had EDNS.
1247
1248 :param bool add: Whether to add EDNS, default is true.
1249
1250 .. function:: setPayloadSizeOnSelfGeneratedAnswers(payloadSize)
1251
1252 .. versionadded:: 1.3.3
1253
1254 Set the UDP payload size advertised via EDNS on self-generated responses. In accordance with
1255 :rfc:`RFC 6891 <6891#section-6.2.5>`, values lower than 512 will be treated as equal to 512.
1256
1257 :param int payloadSize: The responder's maximum UDP payload size, in bytes. Default is 1500.
1258
1259 Security Polling
1260 ~~~~~~~~~~~~~~~~
1261
1262 PowerDNS products can poll the security status of their respective versions. This polling, naturally,
1263 happens over DNS. If the result is that a given version has a security problem, the software will
1264 report this at level ‘Error’ during startup, and repeatedly during operations, every
1265 :func:`setSecurityPollInterval` seconds.
1266
1267 By default, security polling happens on the domain ‘secpoll.powerdns.com’, but this can be changed with
1268 the :func:`setSecurityPollSuffix` function. If this setting is made empty, no polling will take place.
1269 Organizations wanting to host their own security zones can do so by changing this setting to a domain name
1270 under their control.
1271
1272 To enable distributors of PowerDNS to signal that they have backported versions, the PACKAGEVERSION
1273 compilation-time macro can be used to set a distributor suffix.
1274
1275 .. function:: setSecurityPollInterval(interval)
1276
1277 .. versionadded:: 1.3.3
1278
1279 Set the interval, in seconds, between two security pollings.
1280
1281 :param int interval: The interval, in seconds, between two pollings. Default is 3600.
1282
1283 .. function:: setSecurityPollSuffix(suffix)
1284
1285 .. versionadded:: 1.3.3
1286
1287 Domain name from which to query security update notifications. Setting this to an empty string disables secpoll.
1288
1289 :param string suffix: The suffix to use, default is 'secpoll.powerdns.com.'.