]> git.ipfire.org Git - thirdparty/pdns.git/blame - pdns/dnsdistdist/docs/reference/config.rst
auth: Remove XPF records from the regression's tests example zone
[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
24* :class:`DNSHeader`: represents the header of a DNS packet
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
43 :param str path: The directory to load the configuration from
44
45Listen Sockets
46~~~~~~~~~~~~~~
47
48.. function:: addLocal(address[, options])
49
50 .. versionadded:: 1.2.0
51
52 Add to the list of listen addresses.
53
54 :param str address: The IP Address with an optional port to listen on.
55 The default port is 53.
56 :param table options: A table with key: value pairs with listen options.
57
58 Options:
59
60 * ``doTCP=true``: bool - Also bind on TCP on ``address``.
61 * ``reusePort=false``: bool - Set the ``SO_REUSEPORT`` socket option.
4bc167b8
RG
62 * ``tcpFastOpenSize=0``: int - Set the TCP Fast Open queue size, enabling TCP Fast Open when available and the value is larger than 0.
63 * ``interface=""``: str - Set the network interface to use.
64 * ``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
65
66 .. code-block:: lua
67
68 addLocal('0.0.0.0:5300', { doTCP=true, reusePort=true })
69
70 This will bind to both UDP and TCP on port 5300 with SO_REUSEPORT enabled.
71
72.. function:: addLocal(address[[[,do_tcp], so_reuseport], tcp_fast_open_qsize])
73
74 .. deprecated:: 1.2.0
75
76 Add to the list of addresses listened on.
77
78 :param str address: The IP Address with an optional port to listen on.
79 The default port is 53.
80 :param bool do_tcp: Also bind a TCP port on ``address``, defaults to true.
81 :param bool so_reuseport: Use ``SO_REUSEPORT`` if it is available, defaults to false
5d31a326
RG
82 :param int tcp_fast_open_qsize: The size of the TCP Fast Open queue. Set to a number
83 higher than 0 to enable TCP Fast Open when available.
84 Default is 0.
20d81666 85
a227f47d
RG
86.. function:: addTLSLocal(address, certFile, keyFile[, options])
87
88 .. versionadded:: 1.3.0
89
90 Listen on the specified address and TCP port for incoming DNS over TLS connections, presenting the specified X.509 certificate.
91
92 :param str address: The IP Address with an optional port to listen on.
93 The default port is 853.
94 :param str certFile: The path to a X.509 certificate file in PEM format.
95 :param str keyFile: The path to the private key file corresponding to the certificate.
96 :param table options: A table with key: value pairs with listen options.
97
98 Options:
99
100 * ``doTCP=true``: bool - Also bind on TCP on ``address``.
101 * ``reusePort=false``: bool - Set the ``SO_REUSEPORT`` socket option.
102 * ``tcpFastOpenSize=0``: int - Set the TCP Fast Open queue size, enabling TCP Fast Open when available and the value is larger than 0.
103 * ``interface=""``: str - Set the network interface to use.
104 * ``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.
105 * ``provider``: str - The TLS library to use between GnuTLS and OpenSSL, if they were available and enabled at compilation time.
106 * ``ciphers``: str - The TLS ciphers to use. The exact format depends on the provider used.
107 * ``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.
108 * ``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.
109 * ``ticketsKeysRotationDelay``: int - Set the delay before the TLS tickets key is rotated, in seconds. Default is 43200 (12h).
110
20d81666
PL
111.. function:: setLocal(address[, options])
112
113 .. versionadded:: 1.2.0
114
115 Remove the list of listen addresses and add a new one.
116
117 :param str address: The IP Address with an optional port to listen on.
118 The default port is 53.
119 :param table options: A table with key: value pairs with listen options.
120
121 The options that can be set are the same as :func:`addLocal`.
122
123.. function:: setLocal(address[[[,do_tcp], so_reuseport], tcp_fast_open_qsize])
124
125 .. deprecated:: 1.2.0
126
127 Remove the list of listen addresses and add a new one.
128
129 :param str address: The IP Address with an optional port to listen on.
130 The default port is 53.
131 :param bool do_tcp: Also bind a TCP port on ``address``, defaults to true.
132 :param bool so_reuseport: Use ``SO_REUSEPORT`` if it is available, defaults to false
5d31a326
RG
133 :param int tcp_fast_open_qsize: The size of the TCP Fast Open queue. Set to a number
134 higher than 0 to enable TCP Fast Open when available.
135 Default is 0.
20d81666
PL
136
137Control Socket, Console and Webserver
138~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
139
140.. function:: controlSocket(address)
141
142 Bind to ``addr`` and listen for a connection for the console
143
144 :param str address: An IP address with optional port. By default, the port is 5199.
145
6f2a4580
PD
146.. function:: inClientStartup()
147
148 Returns true while the console client is parsing the configuration.
149
20d81666
PL
150.. function:: makeKey()
151
152 Generate and print an encryption key.
153
506bb661
RG
154.. function:: setConsoleConnectionsLogging(enabled)
155
156 .. versionadded:: 1.2.0
157
158 Whether to log the opening and closing of console connections.
159
160 :param bool enabled: Default to true.
161
20d81666
PL
162.. function:: setKey(key)
163
164 Use ``key`` as shared secret between the client and the server
165
166 :param str key: An encoded key, as generated by :func:`makeKey`
167
168.. function:: testCrypto()
169
170 Test the crypto code, will report errors when something is not ok.
171
172Webserver
173~~~~~~~~~
174
175.. function:: webServer(listen_address, password[, apikey[, custom_headers]])
176
177 Launch the :doc:`../guides/webserver` with statistics and the API.
178
179 :param str listen_address: The IP address and Port to listen on
180 :param str password: The password required to access the webserver
181 :param str apikey: The key required to access the API
182 :param {[str]=str,...} custom_headers: Allows setting custom headers and removing the defaults
183
184.. function:: setAPIWritable(allow [,dir])
185
186 Allow modifications via the API.
187 Optionally saving these changes to disk.
188 Modifications done via the API will not be written to the configuration by default and will not persist after a reload
189
190 :param bool allow: Set to true to allow modification through the API
191 :param str dir: A valid directory where the configuration files will be written by the API.
192
193Access Control Lists
194~~~~~~~~~~~~~~~~~~~~
195
196.. function:: addACL(netmask)
197
198 Add a netmask to the existing ACL
199
200 :param str netmask: A CIDR netmask, e.g. ``"192.0.2.0/24"``. Without a subnetmask, only the specific address is allowed.
201
202.. function:: setACL(netmasks)
203
204 Remove the existing ACL and add the netmasks from the table.
205
206 :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.
207
208EDNS Client Subnet
209~~~~~~~~~~~~~~~~~~
210
211.. function:: setECSSourcePrefixV4(prefix)
212
213 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
214
215 :param int prefix: The prefix length
216
217.. function:: setECSSourcePrefixV6(prefix)
218
219 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
220
221 :param int prefix: The prefix length
222
223Ringbuffers
224~~~~~~~~~~~
225
226.. function:: setRingBuffersSize(num)
227
228 Set the capacity of the ringbuffers used for live traffic inspection to ``num``
229
230 :param int num: The maximum amount of queries to keep in the ringbuffer. Defaults to 10000
231
232Servers
233-------
234
235.. function:: newServer(server_string)
236 newServer(server_table)
237
238 Add a new backend server. Call this function with either a string::
239
240 newServer(
241 "IP:PORT" -- IP and PORT of the backend server
242 )
243
244 or a table::
245
246 newServer({
247 address="IP:PORT", -- IP and PORT of the backend server (mandatory)
5cc8371b
RG
248 addXPF=BOOL, -- Add the client's IP address and port to the query, along with the original destination address and port,
249 -- using the experimental XPF record from `draft-bellis-dnsop-xpf`. Default to false
c19aa18d
RG
250 qps=NUM, -- Limit the number of queries per second to NUM, when using the `firstAvailable` policy
251 order=NUM, -- The order of this server, used by the `leastOustanding` and `firstAvailable` policies
252 weight=NUM, -- The weight of this server, used by the `wrandom` and `whashed` policies
5d31a326
RG
253 pool=STRING|{STRING}, -- The pools this server belongs to (unset or empty string means default pool) as a string or table of strings
254 retries=NUM, -- The number of TCP connection attempts to the backend, for a given query
255 tcpConnectTimeout=NUM, -- The timeout (in seconds) of a TCP connection attempt
256 tcpSendTimeout=NUM, -- The timeout (in seconds) of a TCP write attempt
257 tcpRecvTimeout=NUM, -- The timeout (in seconds) of a TCP read attempt
258 tcpFastOpen=BOOL, -- Whether to enable TCP Fast Open
c0e7123d 259 ipBindAddrNoPort=BOOL, -- Whether to enable IP_BIND_ADDRESS_NO_PORT if available, default: true
5d31a326 260 name=STRING, -- The name associated to this backend, for display purpose
de9f7157 261 checkClass=NUM, -- Use NUM as QCLASS in the health-check query, default: DNSClass.IN
20d81666
PL
262 checkName=STRING, -- Use STRING as QNAME in the health-check query, default: "a.root-servers.net."
263 checkType=STRING, -- Use STRING as QTYPE in the health-check query, default: "A"
264 setCD=BOOL, -- Set the CD (Checking Disabled) flag in the health-check query, default: false
265 maxCheckFailures=NUM, -- Allow NUM check failures before declaring the backend down, default: false
266 mustResolve=BOOL, -- Set to true when the health check MUST return a NOERROR RCODE and an answer
267 useClientSubnet=BOOL, -- Add the client's IP address in the EDNS Client Subnet option when forwarding the query to this backend
268 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
269 -- The following formats are supported:
270 -- "address", e.g. "192.0.2.2"
271 -- "interface name", e.g. "eth0"
272 -- "address@interface", e.g. "192.0.2.2@eth0"
273 })
274
275 :param str server_string: A simple IP:PORT string.
276 :param table server_table: A table with at least a 'name' key
277
278.. function:: getServer(index) -> Server
279
280 Get a :class:`Server`
281
282 :param int index: The number of the server (as seen in :func:`showServers`).
283 :returns: The :class:`Server` object or nil
284
285.. function:: getServers()
286
287 Returns a table with all defined servers.
288
289.. function:: rmServer(index)
290 rmServer(server)
291
292 Remove a backend server.
293
294 :param int index: The number of the server (as seen in :func:`showServers`).
295 :param Server server: A :class:`Server` object as returned by e.g. :func:`getServer`.
296
297Server Functions
298~~~~~~~~~~~~~~~~
299A server object returned by :func:`getServer` can be manipulated with these functions.
300
301.. class:: Server
302
303 This object represents a backend server. It has several methods.
304
305.. classmethod:: Server:addPool(pool)
306
307 Add this server to a pool.
308
309 :param str pool: The pool to add the server to
310
311.. classmethod:: Server:getName() -> string
312
313 Get the name of this server.
314
315 :returns: The name of the server, or an empty string if it does not have one
316
317.. classmethod:: Server:getNameWithAddr() -> string
318
319 Get the name plus IP address and port of the server
320
321 :returns: A string containing the server name if any plus the server address and port
322
323.. classmethod:: Server:getOutstanding() -> int
324
325 Get the number of outstanding queries for this server.
326
327 :returns: The number of outstanding queries
328
329.. classmethod:: Server:isUp() -> bool
330
331 Returns the up status of the server
332
333 :returns: true when the server is up, false otherwise
334
335.. classmethod:: Server:rmPool(pool)
336
337 Removes the server from the named pool
338
339 :param str pool: The pool to remove the server from
340
d92708ed
RG
341.. classmethod:: Server:setAuto([status])
342
343.. versionchanged:: 1.3.0
344 ``status`` optional parameter added.
20d81666
PL
345
346 Set the server in the default auto state.
d92708ed
RG
347 This will enable health check queries that will set the server ``up`` and ``down`` appropriately.
348
349 :param bool status: Set the initial status of the server to ``up`` (true) or ``down`` (false) instead of using the last known status
20d81666
PL
350
351.. classmethod:: Server:setQPS(limit)
352
353 Limit the queries per second for this server.
354
355 :param int limit: The maximum number of queries per second
356
357.. classmethod:: Server:setDown()
358
359 Set the server in an ``DOWN`` state.
360 The server will not receive queries and the health checks are disabled
361
362.. classmethod:: Server:setUp()
363
364 Set the server in an ``UP`` state.
365 This server will still receive queries and health checks are disabled
366
367Attributes
368~~~~~~~~~~
369
370.. attribute:: Server.name
371
372 The name of the server
373
374.. attribute:: Server.upStatus
375
376 Whether or not this server is up or down
377
378.. attribute:: Server.order
379
380 The order of the server
381
382.. attribute:: Server.weight
383
384 The weight of the server
385
386Pools
387-----
388
389:class:`Server`\ s can be part of any number of pools.
5d31a326
RG
390Pools are automatically created when a server is added to a pool (with :func:`newServer`), or can be manually created with :func:`addPool`.
391
392.. function:: addPool(name) -> ServerPool
393
394 Returns a :class:`ServerPool`.
395
396 :param string name: The name of the pool to create
20d81666
PL
397
398.. function:: getPool(name) -> ServerPool
399
400 Returns a :class:`ServerPool` or nil.
401
402 :param string name: The name of the pool
403
5d31a326
RG
404.. function:: rmPool(name)
405
406 Remove the pool named `name`.
407
408 :param string name: The name of the pool to remove
409
20d81666
PL
410.. function:: getPoolServers(name) -> [ Server ]
411
412 Returns a list of :class:`Server`\ s or nil.
413
414 :param string name: The name of the pool
415
416.. class:: ServerPool
417
418 This represents the pool where zero or more servers are part of.
419
420.. classmethod:: ServerPool:getCache() -> PacketCache
421
422 Returns the :class:`PacketCache` for this pool or nil.
423
424.. classmethod:: ServerPool:setCache(cache)
425
426 Adds ``cache`` as the pool's cache.
427
428 :param PacketCache cache: The new cache to add to the pool
429
430.. classmethod:: ServerPool:unsetCache()
431
432 Removes the cache from this pool.
433
434PacketCache
435~~~~~~~~~~~
436
437A Pool can have a packet cache to answer queries directly in stead of going to the backend.
438See :doc:`../guides/cache` for a how to.
439
4bc167b8
RG
440.. function:: newPacketCache(maxEntries[, maxTTL=86400[, minTTL=0[, temporaryFailureTTL=60[, staleTTL=60[, dontAge=false[, numberOfShards=1[, deferrableInsertLock=true]]]]]]]) -> PacketCache
441
442 .. versionchanged:: 1.2.0
443 ``numberOfShard`` and ``deferrableInsertLock`` parameters added.
20d81666
PL
444
445 Creates a new :class:`PacketCache` with the settings specified.
446
447 :param int maxEntries: The maximum number of entries in this cache
448 :param int maxTTL: Cap the TTL for records to his number
449 :param int minTTL: Don't cache entries with a TTL lower than this
450 :param int temporaryFailureTTL: On a SERVFAIL or REFUSED from the backend, cache for this amount of seconds
451 :param int staleTTL: When the backend servers are not reachable, send responses if the cache entry is expired at most this amount of seconds
4bc167b8
RG
452 :param bool dontAge: Don't reduce TTLs when serving from the cache. Use this when :program:`dnsdist` fronts a cluster of authoritative servers
453 :param int numberOfShards: Number of shards to divide the cache into, to reduce lock contention
454 :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
20d81666
PL
455
456.. class:: PacketCache
457
458 Represents a cache that can be part of :class:`ServerPool`.
459
460.. classmethod:: PacketCache:expunge(n)
461
462 Remove entries from the cache, leaving at most ``n`` entries
463
464 :param int n: Number of entries to keep
465
466.. classmethod:: PacketCache:expungeByName(name [, qtype=dnsdist.ANY[, suffixMatch=false]])
467
468 .. versionchanged:: 1.2.0
469 ``suffixMatch`` parameter added.
470
471 Remove entries matching ``name`` and type from the cache.
472
473 :param DNSName name: The name to expunge
474 :param int qtype: The type to expunge
475 :param bool suffixMatch: When set to true, remove al entries under ``name``
476
477.. classmethod:: PacketCache:isFull() -> bool
478
479 Return true if the cache has reached the maximum number of entries.
480
481.. classmethod:: PacketCache:printStats()
482
483 Print the cache stats (hits, misses, deferred lookups and deferred inserts).
484
485.. classmethod:: PacketCache:purgeExpired(n)
486
487 Remove expired entries from the cache until there is at most ``n`` entries remaining in the cache.
488
489 :param int n: Number of entries to keep
490
491.. classmethod:: PacketCache:toString() -> string
492
493 Return the number of entries in the Packet Cache, and the maximum number of entries
494
bd51e34c
RG
495Client State
496------------
497
498Also 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.
499
500.. function:: getBind(index) -> ClientState
501
502 Return a ClientState object.
503
504 :param int index: The object index
505
506ClientState functions
507~~~~~~~~~~~~~~~~~~~~~
508
509.. class:: ClientState
510
511 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.
512
513.. classmethod:: Server:addPool(pool)
514
515 Add this server to a pool.
516
517 :param str pool: The pool to add the server to
518
519.. classmethod:: ClientState:attachFilter(filter)
520
521 Attach a BPF filter to this frontend.
522
523 :param BPFFilter filter: The filter to attach to this frontend
524
525.. classmethod:: ClientState:detachFilter()
526
527 Remove the BPF filter associated to this frontend, if any.
528
529.. classmethod:: ClientState:toString() -> string
530
531 Return the address and port this frontend is listening on.
532
533 :returns: The address and port this frontend is listening on
534
535Attributes
536~~~~~~~~~~
537
538.. attribute:: ClientState.muted
539
540 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.
541
20d81666
PL
542Status, Statistics and More
543---------------------------
544
545.. function:: dumpStats()
546
547 Print all statistics dnsdist gathers
548
a227f47d
RG
549.. function:: getTLSContext(idx)
550 .. versionadded:: 1.3.0
551
552 Return the TLSContext object for the context of index ``idx``.
553
20d81666
PL
554.. function:: grepq(selector[, num])
555 grepq(selectors[, num])
556
557 Prints the last ``num`` queries matching ``selector`` or ``selectors``.
558
559 The selector can be:
560
561 * a netmask (e.g. '192.0.2.0/24')
562 * a DNS name (e.g. 'dnsdist.org')
563 * a response time (e.g. '100ms')
564
565 :param str selector: Select queries based on this property.
566 :param {str} selectors: A lua table of selectors. Only queries matching all selectors are shown
567 :param int num: Show a maximum of ``num`` recent queries, default is 10.
568
569.. function:: showACL()
570
571 Print a list of all allowed netmasks.
572
77d43b54
RG
573.. function:: showBinds()
574
575 Print a list of all the current addresses and ports dnsdist is listening on, also called ``frontends``
576
20d81666
PL
577.. function:: showResponseLatency()
578
77d43b54 579 Show a plot of the response time latency distribution
20d81666
PL
580
581.. function:: showServers()
582
583 This function shows all backend servers currently configured and some statistics.
584 These statics have the following fields:
585
586 * ``#`` - The number of the server, can be used as the argument for :func:`getServer`
587 * ``Address`` - The IP address and port of the server
588 * ``State`` - The current state of the server
589 * ``Qps`` - Current number of queries per second
590 * ``Qlim`` - Configured maximum number of queries per second
591 * ``Ord`` - The order number of the server
592 * ``Wt`` - The weight of the server
593 * ``Queries`` - Total amount of queries sent to this server
594 * ``Drops`` - Number of queries that were dropped by this server
595 * ``Drate`` - Number of queries dropped per second by this server
596 * ``Lat`` - The latency of this server in milliseconds
597 * ``Pools`` - The pools this server belongs to
598
599.. function:: showTCPStats()
600
77d43b54 601 Show some statistics regarding TCP
20d81666 602
a227f47d
RG
603.. function:: showTLSContexts()
604 .. versionadded:: 1.3.0
605
606 Print the list of all availables DNS over TLS contexts.
607
20d81666
PL
608.. function:: showVersion()
609
610 Print the version of dnsdist
611
612.. function:: topBandwidth([num])
613
614 Print the top ``num`` clients that consume the most bandwidth.
615
616 :param int num: Number to show, defaults to 10.
617
618.. function:: topClients([num])
619
620 Print the top ``num`` clients sending the most queries over length of ringbuffer
621
622 :param int num: Number to show, defaults to 10.
623
624.. function:: topQueries([num[, labels]])
625
626 Print the ``num`` most popular QNAMEs from queries.
627 Optionally grouped by the rightmost ``labels`` DNS labels.
628
629 :param int num: Number to show, defaults to 10
630 :param int label: Number of labels to cut down to
631
632.. function:: topResponses([num[, rcode[, labels]]])
633
967f6a7f 634 Print the ``num`` most seen responses with an RCODE of ``rcode``.
20d81666
PL
635 Optionally grouped by the rightmost ``labels`` DNS labels.
636
637 :param int num: Number to show, defaults to 10
967f6a7f 638 :param int rcode: :ref:`Response code <DNSRCode>`, defaults to 0 (No Error)
20d81666
PL
639 :param int label: Number of labels to cut down to
640
641.. function:: topSlow([num[, limit[, labels]]])
642
643 Print the ``num`` slowest queries that are slower than ``limit`` milliseconds.
644 Optionally grouped by the rightmost ``labels`` DNS labels.
645
646 :param int num: Number to show, defaults to 10
af4b7afb 647 :param int limit: Show queries slower than this amount of milliseconds, defaults to 2000
20d81666
PL
648 :param int label: Number of labels to cut down to
649
650.. _dynblocksref:
651
652Dynamic Blocks
653--------------
654
655.. function:: addDynBlocks(addresses, message[, seconds=10[, action]])
656
657 .. versionchanged:: 1.2.0
658 ``action`` parameter added.
659
660 Block a set of addresses with ``message`` for (optionally) a number of seconds.
661 The default number of seconds to block for is 10.
662
663 :param addresses: set of Addresses as returned by an exceed function
664 :param string message: The message to show next to the blocks
665 :param int seconds: The number of seconds this block to expire
666 :param int action: The action to take when the dynamic block matches, see :ref:`here <DNSAction>`. (default to the one set with :func:`setDynBlocksAction`)
667
668.. function:: clearDynBlocks()
669
670 Remove all current dynamic blocks.
671
672.. function:: showDynBlocks()
673
674 List all dynamic blocks in effect.
675
676.. function:: setDynBlocksAction(action)
677
678 Set which action is performed when a query is blocked.
752d505b 679 Only DNSAction.Drop (the default), DNSAction.Refused and DNSAction.Truncate are supported.
20d81666 680
20d81666
PL
681.. _exceedfuncs:
682
683Getting addresses that exceeded parameters
684~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
685
686.. function:: exceedServFails(rate, seconds)
687
688 Get set of addresses that exceed ``rate`` servfails/s over ``seconds`` seconds
689
690 :param int rate: Number of Servfails per second to exceed
691 :param int seconds: Number of seconds the rate has been exceeded
692
693.. function:: exceedNXDOMAINs(rate, seconds)
694
695 get set of addresses that exceed ``rate`` NXDOMAIN/s over ``seconds`` seconds
696
697 :param int rate: Number of NXDOMAIN per second to exceed
698 :param int seconds: Number of seconds the rate has been exceeded
699
700.. function:: exceedRespByterate(rate, seconds)
701
702 get set of addresses that exceeded ``rate`` bytes/s answers over ``seconds`` seconds
703
704 :param int rate: Number of bytes per second to exceed
705 :param int seconds: Number of seconds the rate has been exceeded
706
707.. function:: exceedQRate(rate, seconds)
708
709 Get set of address that exceed ``rate`` queries/s over ``seconds`` seconds
710
711 :param int rate: Number of queries per second to exceed
712 :param int seconds: Number of seconds the rate has been exceeded
713
714.. function:: exceedQTypeRate(type, rate, seconds)
715
716 Get set of address that exceed ``rate`` queries/s for queries of QType ``type`` over ``seconds`` seconds
717
718 :param int type: QType
719 :param int rate: Number of QType queries per second to exceed
720 :param int seconds: Number of seconds the rate has been exceeded
721
722Other functions
723---------------
724
725.. function:: maintenance()
726
727 If this function exists, it is called every second to so regular tasks.
728 This can be used for e.g. :doc:`Dynamic Blocks <../guides/dynblocks>`.
a227f47d
RG
729
730TLSContext
731~~~~~~~~~~
732
733.. class:: TLSContext
734 .. versionadded:: 1.3.0
735
736 This object represents an address and port dnsdist is listening on for DNS over TLS queries.
737
738.. classmethod:: TLSContext:rotateTicketsKey()
739
740 Replace the current TLS tickets key by a new random one.
741
742.. classmethod:: TLSContext:loadTicketsKeys(ticketsKeysFile)
743
744 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.
745
746 :param str ticketsKeysFile: The path to a file from where TLS tickets keys should be loaded.