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