3 Configuration Reference
4 =======================
6 This page lists all configuration options for dnsdist.
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".
16 Within dnsdist several core object types exist:
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
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:
31 getServer(0).order=12 -- set order of server 0 to 12
32 getServer(0):addPool("abuse") -- add this server to the abuse pool
34 The ``.`` means ``order`` is a data member, while the ``:`` means ``addPool`` is a member function.
39 .. function:: includeDirectory(path)
41 Include configuration files from ``path``.
43 :param str path: The directory to load configuration files from. Each file must end in ``.conf``.
45 .. function:: reloadAllCertificates()
47 .. versionadded:: 1.4.0
49 Reload all DNSCrypt and TLS certificates, along with their associated keys.
51 .. function:: setSyslogFacility(facility)
53 .. versionadded:: 1.4.0
55 Set the syslog logging facility to ``facility``.
57 :param int facility: The new facility as a numeric value. Defaults to LOG_DAEMON.
62 .. function:: addLocal(address[, options])
64 .. versionadded:: 1.2.0
66 .. versionchanged:: 1.3.0
67 Added ``cpus`` to the options.
69 .. versionchanged:: 1.4.0
70 Removed ``doTCP`` from the options. A listen socket on TCP is always created.
72 Add to the list of listen addresses.
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.
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.
88 addLocal('0.0.0.0:5300', { reusePort=true })
90 This will bind to both UDP and TCP on port 5300 with SO_REUSEPORT enabled.
92 .. function:: addLocal(address[[[,do_tcp], so_reuseport], tcp_fast_open_qsize])
96 Add to the list of addresses listened on.
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.
106 .. function:: addDOHLocal(address, [certFile(s) [, keyFile(s) [, urls [, options]]]])
108 .. versionadded:: 1.4.0
110 .. versionchanged:: 1.5.0
111 ``sendCacheControlHeaders`` option added.
113 Listen on the specified address and TCP port for incoming DNS over HTTPS connections, presenting the specified X.509 certificate.
114 If no certificate (or key) files are specified, listen for incoming DNS over HTTP connections instead.
116 :param str address: The IP Address with an optional port to listen on.
117 The default port is 443.
118 :param str certFile(s): The path to a X.509 certificate file in PEM format, or a list of paths to such files.
119 :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.
120 :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 /.
121 :param table options: A table with key: value pairs with listen options.
125 * ``reusePort=false``: bool - Set the ``SO_REUSEPORT`` socket option.
126 * ``tcpFastOpenQueueSize=0``: int - Set the TCP Fast Open queue size, enabling TCP Fast Open when available and the value is larger than 0.
127 * ``interface=""``: str - Set the network interface to use.
128 * ``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.
129 * ``idleTimeout=30``: int - Set the idle timeout, in seconds.
130 * ``ciphers``: str - The TLS ciphers to use, in OpenSSL format. Ciphers for TLS 1.3 must be specified via ``ciphersTLS13``.
131 * ``ciphersTLS13``: str - The TLS ciphers to use for TLS 1.3, in OpenSSL format.
132 * ``serverTokens``: str - The content of the Server: HTTP header returned by dnsdist. The default is "h2o/dnsdist".
133 * ``customResponseHeaders={}``: table - Set custom HTTP header(s) returned by dnsdist.
134 * ``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.
135 * ``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.
136 * ``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.
137 * ``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.
138 * ``ticketsKeysRotationDelay``: int - Set the delay before the TLS tickets key is rotated, in seconds. Default is 43200 (12h).
139 * ``sessionTickets``: bool - Whether session resumption via session tickets is enabled. Default is true, meaning tickets are enabled.
140 * ``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.
141 * ``preferServerCiphers``: bool - Whether to prefer the order of ciphers set by the server instead of the one set by the client. Default is true, meaning that the order of the server is used.
142 * ``keyLogFile``: str - Write the TLS keys in the specified file so that an external program can decrypt TLS exchanges, in the format described in https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/Key_Log_Format.
143 * ``sendCacheControlHeaders``: bool - Whether to parse the response to find the lowest TTL and set a HTTP Cache-Control header accordingly. Default is true.
145 .. function:: addTLSLocal(address, certFile(s), keyFile(s) [, options])
147 .. versionadded:: 1.3.0
148 .. versionchanged:: 1.3.1
149 ``certFile(s)`` and ``keyFile(s)`` parameters accept a list of files.
150 ``sessionTickets`` option added.
151 .. versionchanged:: 1.3.3
152 ``numberOfStoredSessions`` option added.
153 .. versionchanged:: 1.4.0
154 ``ciphersTLS13``, ``minTLSVersion``, ``ocspResponses``, ``preferServerCiphers``, ``keyLogFile`` options added.
156 Listen on the specified address and TCP port for incoming DNS over TLS connections, presenting the specified X.509 certificate.
158 :param str address: The IP Address with an optional port to listen on.
159 The default port is 853.
160 :param str certFile(s): The path to a X.509 certificate file in PEM format, or a list of paths to such files.
161 :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.
162 :param table options: A table with key: value pairs with listen options.
166 * ``reusePort=false``: bool - Set the ``SO_REUSEPORT`` socket option.
167 * ``tcpFastOpenQueueSize=0``: int - Set the TCP Fast Open queue size, enabling TCP Fast Open when available and the value is larger than 0.
168 * ``interface=""``: str - Set the network interface to use.
169 * ``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.
170 * ``provider``: str - The TLS library to use between GnuTLS and OpenSSL, if they were available and enabled at compilation time. Default is to use OpenSSL when available.
171 * ``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``.
172 * ``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.
173 * ``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.
174 * ``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.
175 * ``ticketsKeysRotationDelay``: int - Set the delay before the TLS tickets key is rotated, in seconds. Default is 43200 (12h).
176 * ``sessionTickets``: bool - Whether session resumption via session tickets is enabled. Default is true, meaning tickets are enabled.
177 * ``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.
178 * ``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.
179 * ``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.
180 * ``preferServerCiphers``: bool - Whether to prefer the order of ciphers set by the server instead of the one set by the client. Default is true, meaning that the order of the server is used.
181 * ``keyLogFile``: str - Write the TLS keys in the specified file so that an external program can decrypt TLS exchanges, in the format described in https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/Key_Log_Format.
183 .. function:: setLocal(address[, options])
185 .. versionadded:: 1.2.0
187 Remove the list of listen addresses and add a new one.
189 :param str address: The IP Address with an optional port to listen on.
190 The default port is 53.
191 :param table options: A table with key: value pairs with listen options.
193 The options that can be set are the same as :func:`addLocal`.
195 .. function:: setLocal(address[[[,do_tcp], so_reuseport], tcp_fast_open_qsize])
197 .. deprecated:: 1.2.0
199 Remove the list of listen addresses and add a new one.
201 :param str address: The IP Address with an optional port to listen on.
202 The default port is 53.
203 :param bool do_tcp: Also bind a TCP port on ``address``, defaults to true.
204 :param bool so_reuseport: Use ``SO_REUSEPORT`` if it is available, defaults to false
205 :param int tcp_fast_open_qsize: The size of the TCP Fast Open queue. Set to a number
206 higher than 0 to enable TCP Fast Open when available.
209 Control Socket, Console and Webserver
210 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
212 .. function:: addConsoleACL(netmask)
214 .. versionadded:: 1.3.0
216 Add a netmask to the existing console ACL, allowing remote clients to connect to the console. Please make sure that encryption
217 has been enabled with :func:`setKey` before doing so. The default is to only allow 127.0.0.1/8 and ::1/128.
219 :param str netmask: A CIDR netmask, e.g. ``"192.0.2.0/24"``. Without a subnetmask, only the specific address is allowed.
221 .. function:: controlSocket(address)
223 Bind to ``addr`` and listen for a connection for the console. Since 1.3.0 only connections from local users are allowed
224 by default, :func:`addConsoleACL` and :func:`setConsoleACL` can be used to enable remote connections. Please make sure
225 that encryption has been enabled with :func:`setKey` before doing so. Enabling encryption is also strongly advised for
226 local connections, since not enabling it allows any local user to connect to the console.
228 :param str address: An IP address with optional port. By default, the port is 5199.
230 .. function:: inClientStartup()
232 Returns true while the console client is parsing the configuration.
234 .. function:: inConfigCheck()
236 .. versionadded:: 1.5.0
238 Returns true while the configuration is being checked, ie when run with ``--check-config``.
240 .. function:: makeKey()
242 Generate and print an encryption key.
244 .. function:: setConsoleConnectionsLogging(enabled)
246 .. versionadded:: 1.2.0
248 Whether to log the opening and closing of console connections.
250 :param bool enabled: Default to true.
252 .. function:: setKey(key)
254 Use ``key`` as shared secret between the client and the server
256 :param str key: An encoded key, as generated by :func:`makeKey`
258 .. function:: setConsoleACL(netmasks)
260 .. versionadded:: 1.3.0
262 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
263 has been enabled with :func:`setKey` before doing so.
265 :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.
267 .. function:: showConsoleACL()
269 Print a list of all netmasks allowed to connect to the console.
271 .. function:: testCrypto()
273 Test the crypto code, will report errors when something is not ok.
275 .. function:: setConsoleOutputMaxMsgSize(size)
277 .. versionadded:: 1.3.3
279 Set the maximum size in bytes of a single console message, default set to 10 MB.
281 :param int size: The new maximum size.
283 Webserver configuration
284 ~~~~~~~~~~~~~~~~~~~~~~~
286 .. function:: webserver(listen_address, password[, apikey[, custom_headers]])
288 Launch the :doc:`../guides/webserver` with statistics and the API.
290 :param str listen_address: The IP address and Port to listen on
291 :param str password: The password required to access the webserver
292 :param str apikey: The key required to access the API
293 :param {[str]=str,...} custom_headers: Allows setting custom headers and removing the defaults
295 .. function:: setAPIWritable(allow [,dir])
297 Allow modifications via the API.
298 Optionally saving these changes to disk.
299 Modifications done via the API will not be written to the configuration by default and will not persist after a reload
301 :param bool allow: Set to true to allow modification through the API
302 :param str dir: A valid directory where the configuration files will be written by the API.
304 .. function:: setWebserverConfig(options)
306 .. versionadded:: 1.3.3
308 Setup webserver configuration. See :func:`webserver`.
310 :param table options: A table with key: value pairs with webserver options.
314 * ``password=newPassword``: string - Changes the API password
315 * ``apiKey=newKey``: string - Changes the API Key (set to an empty string do disable it)
316 * ``custom_headers={[str]=str,...}``: map of string - Allows setting custom headers and removing the defaults.
321 .. function:: addACL(netmask)
323 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.
325 :param str netmask: A CIDR netmask, e.g. ``"192.0.2.0/24"``. Without a subnetmask, only the specific address is allowed.
327 .. function:: setACL(netmasks)
329 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.
331 :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.
333 .. function:: showACL()
335 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.
340 .. function:: setECSOverride(bool)
342 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
344 :param bool: Whether to override an existing EDNS Client Subnet option present in the query. Defaults to false
346 .. function:: setECSSourcePrefixV4(prefix)
348 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
350 :param int prefix: The prefix length
352 .. function:: setECSSourcePrefixV6(prefix)
354 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
356 :param int prefix: The prefix length
361 .. function:: setRingBuffersLockRetries(num)
363 .. versionadded:: 1.3.0
365 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
367 :param int num: The maximum number of attempts. Defaults to 5 if there is more than one shard, 0 otherwise.
369 .. function:: setRingBuffersSize(num [, numberOfShards])
371 .. versionchanged:: 1.3.0
372 ``numberOfShards`` optional parameter added.
374 Set the capacity of the ringbuffers used for live traffic inspection to ``num``, and the number of shards to ``numberOfShards`` if specified.
376 :param int num: The maximum amount of queries to keep in the ringbuffer. Defaults to 10000
377 :param int numberOfShards: the number of shards to use to limit lock contention. Defaults to 1
382 .. function:: newServer(server_string)
383 newServer(server_table)
385 .. versionchanged:: 1.3.0
386 Added ``checkClass``, ``sockets`` and ``checkFunction`` to server_table.
388 .. versionchanged:: 1.4.0
389 Added ``checkInterval``, ``checkTimeout`` and ``rise`` to server_table.
391 Add a new backend server. Call this function with either a string::
394 "IP:PORT" -- IP and PORT of the backend server
400 address="IP:PORT", -- IP and PORT of the backend server (mandatory)
401 id=STRING, -- Use a pre-defined UUID instead of a random one
402 qps=NUM, -- Limit the number of queries per second to NUM, when using the `firstAvailable` policy
403 order=NUM, -- The order of this server, used by the `leastOutstanding` and `firstAvailable` policies
404 weight=NUM, -- The weight of this server, used by the `wrandom`, `whashed` and `chashed` policies, default: 1
405 -- Supported values are a minimum of 1, and a maximum of 2147483647.
406 pool=STRING|{STRING}, -- The pools this server belongs to (unset or empty string means default pool) as a string or table of strings
407 retries=NUM, -- The number of TCP connection attempts to the backend, for a given query
408 tcpConnectTimeout=NUM, -- The timeout (in seconds) of a TCP connection attempt
409 tcpSendTimeout=NUM, -- The timeout (in seconds) of a TCP write attempt
410 tcpRecvTimeout=NUM, -- The timeout (in seconds) of a TCP read attempt
411 tcpFastOpen=BOOL, -- Whether to enable TCP Fast Open
412 ipBindAddrNoPort=BOOL, -- Whether to enable IP_BIND_ADDRESS_NO_PORT if available, default: true
413 name=STRING, -- The name associated to this backend, for display purpose
414 checkClass=NUM, -- Use NUM as QCLASS in the health-check query, default: DNSClass.IN
415 checkName=STRING, -- Use STRING as QNAME in the health-check query, default: "a.root-servers.net."
416 checkType=STRING, -- Use STRING as QTYPE in the health-check query, default: "A"
417 checkFunction=FUNCTION,-- Use this function to dynamically set the QNAME, QTYPE and QCLASS to use in the health-check query (see :ref:`Healthcheck`)
418 checkTimeout=NUM, -- The timeout (in milliseconds) of a health-check query, default: 1000 (1s)
419 setCD=BOOL, -- Set the CD (Checking Disabled) flag in the health-check query, default: false
420 maxCheckFailures=NUM, -- Allow NUM check failures before declaring the backend down, default: 1
421 checkInterval=NUM -- The time in seconds between health checks
422 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
423 useClientSubnet=BOOL, -- Add the client's IP address in the EDNS Client Subnet option when forwarding the query to this backend
424 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
425 -- The following formats are supported:
426 -- "address", e.g. "192.0.2.2"
427 -- "interface name", e.g. "eth0"
428 -- "address@interface", e.g. "192.0.2.2@eth0"
429 addXPF=NUM, -- Add the client's IP address and port to the query, along with the original destination address and port,
430 -- 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)
431 sockets=NUM, -- Number of sockets (and thus source ports) used toward the backend server, defaults to a single one
432 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. This requires the ``parseECS`` option of the corresponding cache to be set to true
433 rise=NUM -- Require NUM consecutive successful checks before declaring the backend up, default: 1
436 :param str server_string: A simple IP:PORT string.
437 :param table server_table: A table with at least a 'name' key
439 .. function:: getServer(index) -> Server
441 .. versionchanged:: 1.5.0
442 ``index`` might be an UUID.
444 Get a :class:`Server`
446 :param int or str index: The number of the server (as seen in :func:`showServers`) or its UUID as a string.
447 :returns: The :class:`Server` object or nil
449 .. function:: getServers()
451 Returns a table with all defined servers.
453 .. function:: rmServer(index)
457 .. versionchanged:: 1.5.0
458 ``uuid`` selection added.
460 Remove a backend server.
462 :param int or str index: The number of the server (as seen in :func:`showServers`), its UUID as a string, or a server object.
463 :param Server server: A :class:`Server` object as returned by e.g. :func:`getServer`.
467 A server object returned by :func:`getServer` can be manipulated with these functions.
471 This object represents a backend server. It has several methods.
473 .. method:: Server:addPool(pool)
475 Add this server to a pool.
477 :param str pool: The pool to add the server to
479 .. method:: Server:getName() -> string
481 Get the name of this server.
483 :returns: The name of the server, or an empty string if it does not have one
485 .. method:: Server:getNameWithAddr() -> string
487 Get the name plus IP address and port of the server
489 :returns: A string containing the server name if any plus the server address and port
491 .. method:: Server:getOutstanding() -> int
493 Get the number of outstanding queries for this server.
495 :returns: The number of outstanding queries
497 .. method:: Server:isUp() -> bool
499 Returns the up status of the server
501 :returns: true when the server is up, false otherwise
503 .. method:: Server:rmPool(pool)
505 Removes the server from the named pool
507 :param str pool: The pool to remove the server from
509 .. method:: Server:setAuto([status])
511 .. versionchanged:: 1.3.0
512 ``status`` optional parameter added.
514 Set the server in the default auto state.
515 This will enable health check queries that will set the server ``up`` and ``down`` appropriately.
517 :param bool status: Set the initial status of the server to ``up`` (true) or ``down`` (false) instead of using the last known status
519 .. method:: Server:setQPS(limit)
521 Limit the queries per second for this server.
523 :param int limit: The maximum number of queries per second
525 .. method:: Server:setDown()
527 Set the server in an ``DOWN`` state.
528 The server will not receive queries and the health checks are disabled
530 .. method:: Server:setUp()
532 Set the server in an ``UP`` state.
533 This server will still receive queries and health checks are disabled
535 Apart from the functions, a :class:`Server` object has these attributes:
537 .. attribute:: Server.name
539 The name of the server
541 .. attribute:: Server.upStatus
543 Whether or not this server is up or down
545 .. attribute:: Server.order
547 The order of the server
549 .. attribute:: Server.weight
551 The weight of the server
556 :class:`Server`\ s can be part of any number of pools.
557 Pools are automatically created when a server is added to a pool (with :func:`newServer`), or can be manually created with :func:`addPool`.
559 .. function:: addPool(name) -> ServerPool
561 Returns a :class:`ServerPool`.
563 :param string name: The name of the pool to create
565 .. function:: getPool(name) -> ServerPool
567 Returns a :class:`ServerPool` or nil.
569 :param string name: The name of the pool
571 .. function:: getPoolServers(name) -> [ Server ]
573 Returns a list of :class:`Server`\ s or nil.
575 :param string name: The name of the pool
577 .. function:: showPools()
579 Display the name, associated cache, server policy and associated servers for every pool.
581 .. class:: ServerPool
583 This represents the pool where zero or more servers are part of.
585 .. method:: ServerPool:getCache() -> PacketCache
587 Returns the :class:`PacketCache` for this pool or nil.
589 .. method:: ServerPool:getECS()
591 .. versionadded:: 1.3.0
593 Whether dnsdist will add EDNS Client Subnet information to the query before looking up into the cache,
594 when all servers from this pool are down. For more information see :meth:`ServerPool:setECS`.
596 .. method:: ServerPool:setCache(cache)
598 Adds ``cache`` as the pool's cache.
600 :param PacketCache cache: The new cache to add to the pool
602 .. method:: ServerPool:unsetCache()
604 Removes the cache from this pool.
606 .. method:: ServerPool:setECS()
608 .. versionadded:: 1.3.0
610 Set to true if dnsdist should add EDNS Client Subnet information to the query before looking up into the cache,
611 when all servers from this pool are down. If at least one server is up, the preference of the
612 selected server is used, this parameter is only useful if all the backends in this pool are down
613 and have EDNS Client Subnet enabled, since the queries in the cache will have been inserted with
614 ECS information. Default is false.
619 A Pool can have a packet cache to answer queries directly instead of going to the backend.
620 See :doc:`../guides/cache` for a how to.
622 .. function:: newPacketCache(maxEntries[, maxTTL=86400[, minTTL=0[, temporaryFailureTTL=60[, staleTTL=60[, dontAge=false[, numberOfShards=1[, deferrableInsertLock=true[, maxNegativeTTL=3600[, parseECS=false]]]]]]]) -> PacketCache
624 .. versionchanged:: 1.3.0
625 ``numberOfShards`` and ``deferrableInsertLock`` parameters added.
627 .. versionchanged:: 1.3.1
628 ``maxNegativeTTL`` and ``parseECS`` parameters added.
630 .. deprecated:: 1.4.0
632 Creates a new :class:`PacketCache` with the settings specified.
634 :param int maxEntries: The maximum number of entries in this cache
635 :param int maxTTL: Cap the TTL for records to his number
636 :param int minTTL: Don't cache entries with a TTL lower than this
637 :param int temporaryFailureTTL: On a SERVFAIL or REFUSED from the backend, cache for this amount of seconds
638 :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
639 :param bool dontAge: Don't reduce TTLs when serving from the cache. Use this when :program:`dnsdist` fronts a cluster of authoritative servers
640 :param int numberOfShards: Number of shards to divide the cache into, to reduce lock contention
641 :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
642 :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
643 :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
645 .. function:: newPacketCache(maxEntries, [options]) -> PacketCache
647 .. versionadded:: 1.4.0
649 Creates a new :class:`PacketCache` with the settings specified.
651 :param int maxEntries: The maximum number of entries in this cache
655 * ``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.
656 * ``dontAge=false``: bool - Don't reduce TTLs when serving from the cache. Use this when :program:`dnsdist` fronts a cluster of authoritative servers.
657 * ``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.
658 * ``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.
659 * ``maxTTL=86400``: int - Cap the TTL for records to his number.
660 * ``minTTL=0``: int - Don't cache entries with a TTL lower than this.
661 * ``numberOfShards=1``: int - Number of shards to divide the cache into, to reduce lock contention.
662 * ``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. Enabling this option is required for the 'zero scope' option to work
663 * ``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.
664 * ``temporaryFailureTTL=60``: int - On a SERVFAIL or REFUSED from the backend, cache for this amount of seconds..
666 .. class:: PacketCache
668 Represents a cache that can be part of :class:`ServerPool`.
670 .. method:: PacketCache:dump(fname)
672 .. versionadded:: 1.3.1
674 Dump a summary of the cache entries to a file.
676 :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.
678 .. method:: PacketCache:expunge(n)
680 Remove entries from the cache, leaving at most ``n`` entries
682 :param int n: Number of entries to keep
684 .. method:: PacketCache:expungeByName(name [, qtype=DNSQType.ANY[, suffixMatch=false]])
686 .. versionchanged:: 1.2.0
687 ``suffixMatch`` parameter added.
689 Remove entries matching ``name`` and type from the cache.
691 :param DNSName name: The name to expunge
692 :param int qtype: The type to expunge, can be a pre-defined :ref:`DNSQType`
693 :param bool suffixMatch: When set to true, remove al entries under ``name``
695 .. method:: PacketCache:getStats()
697 .. versionadded:: 1.4.0
699 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.
701 .. method:: PacketCache:isFull() -> bool
703 Return true if the cache has reached the maximum number of entries.
705 .. method:: PacketCache:printStats()
707 Print the cache stats (number of entries, hits, misses, deferred lookups, deferred inserts, lookup collisions, insert collisions and TTL too shorts).
709 .. method:: PacketCache:purgeExpired(n)
711 Remove expired entries from the cache until there is at most ``n`` entries remaining in the cache.
713 :param int n: Number of entries to keep
715 .. method:: PacketCache:toString() -> string
717 Return the number of entries in the Packet Cache, and the maximum number of entries
722 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.
724 .. function:: getBind(index) -> ClientState
726 Return a :class:`ClientState` object.
728 :param int index: The object index
730 ClientState functions
731 ~~~~~~~~~~~~~~~~~~~~~
733 .. class:: ClientState
735 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.
737 .. method:: ClientState:attachFilter(filter)
739 Attach a BPF filter to this frontend.
741 :param BPFFilter filter: The filter to attach to this frontend
743 .. method:: ClientState:detachFilter()
745 Remove the BPF filter associated to this frontend, if any.
747 .. method:: ClientState:toString() -> string
749 Return the address and port this frontend is listening on.
751 :returns: The address and port this frontend is listening on
753 .. attribute:: ClientState.muted
755 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.
757 Status, Statistics and More
758 ---------------------------
760 .. function:: dumpStats()
762 Print all statistics dnsdist gathers
764 .. function:: getDOHFrontend(idx)
766 .. versionadded:: 1.4.0
768 Return the DOHFrontend object for the DNS over HTTPS bind of index ``idx``.
770 .. function:: getTLSContext(idx)
772 .. versionadded:: 1.3.0
774 Return the TLSContext object for the context of index ``idx``.
776 .. function:: getTLSFrontend(idx)
778 .. versionadded:: 1.3.1
780 Return the TLSFrontend object for the TLS bind of index ``idx``.
782 .. function:: grepq(selector[, num])
783 grepq(selectors[, num])
785 Prints the last ``num`` queries matching ``selector`` or ``selectors``.
789 * a netmask (e.g. '192.0.2.0/24')
790 * a DNS name (e.g. 'dnsdist.org')
791 * a response time (e.g. '100ms')
793 :param str selector: Select queries based on this property.
794 :param {str} selectors: A lua table of selectors. Only queries matching all selectors are shown
795 :param int num: Show a maximum of ``num`` recent queries, default is 10.
797 .. function:: setVerboseHealthChecks(verbose)
799 Set whether health check errors should be logged. This is turned off by default.
801 :param bool verbose: Set to true if you want to enable health check errors logging
803 .. function:: showBinds()
805 Print a list of all the current addresses and ports dnsdist is listening on, also called ``frontends``
807 .. function:: showDOHFrontends()
809 .. versionadded:: 1.4.0
811 Print the list of all availables DNS over HTTPS frontends.
813 .. function:: showDOHResponseCodes()
815 .. versionadded:: 1.4.0
817 Print the HTTP response codes statistics for all availables DNS over HTTPS frontends.
819 .. function:: showResponseLatency()
821 Show a plot of the response time latency distribution
823 .. function:: showServers([options])
825 .. versionchanged:: 1.4.0
826 ``options`` optional parameter added
828 This function shows all backend servers currently configured and some statistics.
829 These statics have the following fields:
831 * ``#`` - The number of the server, can be used as the argument for :func:`getServer`
832 * ``UUID`` - The UUID of the backend. Can be set with the ``id`` option of :func:`newServer`
833 * ``Address`` - The IP address and port of the server
834 * ``State`` - The current state of the server
835 * ``Qps`` - Current number of queries per second
836 * ``Qlim`` - Configured maximum number of queries per second
837 * ``Ord`` - The order number of the server
838 * ``Wt`` - The weight of the server
839 * ``Queries`` - Total amount of queries sent to this server
840 * ``Drops`` - Number of queries that were dropped by this server
841 * ``Drate`` - Number of queries dropped per second by this server
842 * ``Lat`` - The latency of this server in milliseconds
843 * ``Pools`` - The pools this server belongs to
845 :param table options: A table with key: value pairs with display options.
849 * ``showUUIDs=false``: bool - Whether to display the UUIDs, defaults to false.
851 .. function:: showTCPStats()
853 Show some statistics regarding TCP
855 .. function:: showTLSContexts()
857 .. versionadded:: 1.3.0
859 Print the list of all availables DNS over TLS contexts.
861 .. function:: showTLSErrorCounters()
863 .. versionadded:: 1.4.0
865 Display metrics about TLS handshake failures.
867 .. function:: showVersion()
869 Print the version of dnsdist
871 .. function:: topBandwidth([num])
873 Print the top ``num`` clients that consume the most bandwidth.
875 :param int num: Number to show, defaults to 10.
877 .. function:: topClients([num])
879 Print the top ``num`` clients sending the most queries over length of ringbuffer
881 :param int num: Number to show, defaults to 10.
883 .. function:: topQueries([num[, labels]])
885 Print the ``num`` most popular QNAMEs from queries.
886 Optionally grouped by the rightmost ``labels`` DNS labels.
888 :param int num: Number to show, defaults to 10
889 :param int label: Number of labels to cut down to
891 .. function:: topResponses([num[, rcode[, labels]]])
893 Print the ``num`` most seen responses with an RCODE of ``rcode``.
894 Optionally grouped by the rightmost ``labels`` DNS labels.
896 :param int num: Number to show, defaults to 10
897 :param int rcode: :ref:`Response code <DNSRCode>`, defaults to 0 (No Error)
898 :param int label: Number of labels to cut down to
900 .. function:: topSlow([num[, limit[, labels]]])
902 Print the ``num`` slowest queries that are slower than ``limit`` milliseconds.
903 Optionally grouped by the rightmost ``labels`` DNS labels.
905 :param int num: Number to show, defaults to 10
906 :param int limit: Show queries slower than this amount of milliseconds, defaults to 2000
907 :param int label: Number of labels to cut down to
914 .. function:: addDynBlocks(addresses, message[, seconds=10[, action]])
916 .. versionchanged:: 1.2.0
917 ``action`` parameter added.
919 Block a set of addresses with ``message`` for (optionally) a number of seconds.
920 The default number of seconds to block for is 10.
922 :param addresses: set of Addresses as returned by an exceed function
923 :param string message: The message to show next to the blocks
924 :param int seconds: The number of seconds this block to expire
925 :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)
927 Please see the documentation for :func:`setDynBlocksAction` to confirm which actions are supported by the action paramater.
929 .. function:: clearDynBlocks()
931 Remove all current dynamic blocks.
933 .. function:: showDynBlocks()
935 List all dynamic blocks in effect.
937 .. function:: setDynBlocksAction(action)
939 .. versionchanged:: 1.3.3
940 ``DNSAction.NXDomain`` action added.
942 Set which action is performed when a query is blocked.
943 Only DNSAction.Drop (the default), DNSAction.NoOp, DNSAction.NXDomain, DNSAction.Refused, DNSAction.Truncate and DNSAction.NoRecurse are supported.
947 Getting addresses that exceeded parameters
948 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
950 .. function:: exceedServFails(rate, seconds)
952 Get set of addresses that exceed ``rate`` servfails/s over ``seconds`` seconds
954 :param int rate: Number of Servfails per second to exceed
955 :param int seconds: Number of seconds the rate has been exceeded
957 .. function:: exceedNXDOMAINs(rate, seconds)
959 get set of addresses that exceed ``rate`` NXDOMAIN/s over ``seconds`` seconds
961 :param int rate: Number of NXDOMAIN per second to exceed
962 :param int seconds: Number of seconds the rate has been exceeded
964 .. function:: exceedRespByterate(rate, seconds)
966 get set of addresses that exceeded ``rate`` bytes/s answers over ``seconds`` seconds
968 :param int rate: Number of bytes per second to exceed
969 :param int seconds: Number of seconds the rate has been exceeded
971 .. function:: exceedQRate(rate, seconds)
973 Get set of address that exceed ``rate`` queries/s over ``seconds`` seconds
975 :param int rate: Number of queries per second to exceed
976 :param int seconds: Number of seconds the rate has been exceeded
978 .. function:: exceedQTypeRate(type, rate, seconds)
980 Get set of address that exceed ``rate`` queries/s for queries of QType ``type`` over ``seconds`` seconds
982 :param int type: QType
983 :param int rate: Number of QType queries per second to exceed
984 :param int seconds: Number of seconds the rate has been exceeded
989 Instead of using several `exceed*()` lines, dnsdist 1.3.0 introduced a new `DynBlockRulesGroup` object
990 which can be used to group dynamic block rules.
992 See :doc:`../guides/dynblocks` for more information about the case where using a `DynBlockRulesGroup` might be
993 faster than the existing rules.
995 .. function:: dynBlockRulesGroup() -> DynBlockRulesGroup
997 .. versionadded:: 1.3.0
999 Creates a new :class:`DynBlockRulesGroup` object.
1001 .. class:: DynBlockRulesGroup
1003 Represents a group of dynamic block rules.
1005 .. method:: DynBlockRulesGroup:setQueryRate(rate, seconds, reason, blockingTime [, action [, warningRate]])
1007 .. versionchanged:: 1.3.3
1008 ``warningRate`` parameter added.
1010 Adds a query rate-limiting rule, equivalent to:
1012 addDynBlocks(exceedQRate(rate, seconds), reason, blockingTime, action)
1015 :param int rate: Number of queries per second to exceed
1016 :param int seconds: Number of seconds the rate has been exceeded
1017 :param string reason: The message to show next to the blocks
1018 :param int blockingTime: The number of seconds this block to expire
1019 :param int action: The action to take when the dynamic block matches, see :ref:`here <DNSAction>`. (default to the one set with :func:`setDynBlocksAction`)
1020 :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
1022 .. method:: DynBlockRulesGroup:setRCodeRate(rcode, rate, seconds, reason, blockingTime [, action [, warningRate]])
1024 .. versionchanged:: 1.3.3
1025 ``warningRate`` parameter added.
1027 Adds a rate-limiting rule for responses of code ``rcode``, equivalent to:
1029 addDynBlocks(exceedServfails(rcode, rate, seconds), reason, blockingTime, action)
1032 :param int rcode: The response code
1033 :param int rate: Number of responses per second to exceed
1034 :param int seconds: Number of seconds the rate has been exceeded
1035 :param string reason: The message to show next to the blocks
1036 :param int blockingTime: The number of seconds this block to expire
1037 :param int action: The action to take when the dynamic block matches, see :ref:`here <DNSAction>`. (default to the one set with :func:`setDynBlocksAction`)
1038 :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
1040 .. method:: DynBlockRulesGroup:setRCodeRatio(rcode, ratio, seconds, reason, blockingTime, minimumNumberOfResponses [, action [, warningRate]])
1042 .. versionadded:: 1.5.0
1044 Adds a rate-limiting rule for the ratio of responses of code ``rcode`` over the total number of responses for a given client.
1046 :param int rcode: The response code
1047 :param int ratio: Ratio of responses per second of the given rcode over the total number of responses for this client to exceed
1048 :param int seconds: Number of seconds the ratio has been exceeded
1049 :param string reason: The message to show next to the blocks
1050 :param int blockingTime: The number of seconds this block to expire
1051 :param int minimumNumberOfResponses: How many total responses is required for this rule to apply
1052 :param int action: The action to take when the dynamic block matches, see :ref:`here <DNSAction>`. (default to the one set with :func:`setDynBlocksAction`)
1053 :param int warningRatio: If set to a non-zero value, the ratio above which a warning message will be issued and a no-op block inserted
1055 .. method:: DynBlockRulesGroup:setQTypeRate(qtype, rate, seconds, reason, blockingTime [, action [, warningRate]])
1057 .. versionchanged:: 1.3.3
1058 ``warningRate`` parameter added.
1060 Adds a rate-limiting rule for queries of type ``qtype``, equivalent to:
1062 addDynBlocks(exceedQTypeRate(type, rate, seconds), reason, blockingTime, action)
1065 :param int qtype: The qtype
1066 :param int rate: Number of queries per second to exceed
1067 :param int seconds: Number of seconds the rate has been exceeded
1068 :param string reason: The message to show next to the blocks
1069 :param int blockingTime: The number of seconds this block to expire
1070 :param int action: The action to take when the dynamic block matches, see :ref:`here <DNSAction>`. (default to the one set with :func:`setDynBlocksAction`)
1071 :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
1073 .. method:: DynBlockRulesGroup:setResponseByteRate(rate, seconds, reason, blockingTime [, action [, warningRate]])
1075 .. versionchanged:: 1.3.3
1076 ``warningRate`` parameter added.
1078 Adds a bandwidth rate-limiting rule for responses, equivalent to:
1080 addDynBlocks(exceedRespByterate(rate, seconds), reason, blockingTime, action)
1083 :param int rate: Number of bytes per second to exceed
1084 :param int seconds: Number of seconds the rate has been exceeded
1085 :param string reason: The message to show next to the blocks
1086 :param int blockingTime: The number of seconds this block to expire
1087 :param int action: The action to take when the dynamic block matches, see :ref:`here <DNSAction>`. (default to the one set with :func:`setDynBlocksAction`)
1088 :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
1090 .. method:: DynBlockRulesGroup:apply()
1092 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.
1094 .. method:: DynBlockRulesGroup:setQuiet(quiet)
1096 .. versionadded:: 1.4.0
1098 Set whether newly blocked clients or domains should be logged.
1100 :param bool quiet: True means that insertions will not be logged, false that they will. Default is false.
1102 .. method:: DynBlockRulesGroup:excludeRange(netmasks)
1104 .. versionadded:: 1.3.1
1106 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.
1108 :param int netmasks: A netmask, or list of netmasks, as strings, like for example "192.0.2.1/24"
1110 .. method:: DynBlockRulesGroup:includeRange(netmasks)
1112 .. versionadded:: 1.3.1
1114 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.
1116 :param int netmasks: A netmask, or list of netmasks, as strings, like for example "192.0.2.1/24"
1118 .. method:: DynBlockRulesGroup:toString()
1120 .. versionadded:: 1.3.1
1122 Return a string describing the rules and range exclusions of this DynBlockRulesGroup.
1127 A SuffixMatchNode can be used to quickly check whether a given name belongs to a set or not. This is achieved
1128 using an efficient tree structure based on DNS labels, making lookups cheap.
1129 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,
1130 if 'example.com.' is added to the set, 'www.example.com.' and 'sub.www.example.com.' will match as well.
1131 If you are looking for exact name matching, your might want to consider using a :class:`DNSNameSet` instead.
1133 .. function:: newSuffixMatchNode()
1135 Creates a new :class:`SuffixMatchNode`.
1137 .. class:: SuffixMatchNode
1139 Represent a set of DNS suffixes for quick matching.
1141 .. method:: SuffixMatchNode:add(name)
1143 .. versionchanged:: 1.4.0
1144 This method now accepts strings, lists of DNSNames and lists of strings.
1146 Add a suffix to the current set.
1148 :param DNSName name: The suffix to add to the set.
1149 :param string name: The suffix to add to the set.
1150 :param table name: The suffixes to add to the set. Elements of the table should be of the same type, either DNSName or string.
1152 .. method:: SuffixMatchNode:check(name) -> bool
1154 Return true if the given name is a sub-domain of one of those in the set, and false otherwise.
1156 :param DNSName name: The name to test against the set.
1161 .. function:: maintenance()
1163 If this function exists, it is called every second to so regular tasks.
1164 This can be used for e.g. :doc:`Dynamic Blocks <../guides/dynblocks>`.
1166 .. function:: setAllowEmptyResponse()
1168 .. versionadded:: 1.4.0
1170 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.
1172 .. function:: makeIPCipherKey(password) -> string
1174 .. versionadded:: 1.4.0
1176 Hashes the password to generate a 16-byte key that can be used to pseudonymize IP addresses with IP cipher.
1178 .. function:: generateOCSPResponse(pathToServerCertificate, pathToCACertificate, pathToCAPrivateKey, outputFile, numberOfDaysOfValidity, numberOfMinutesOfValidity)
1180 .. versionadded:: 1.4.0
1182 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.
1183 The resulting file can be directly used with the :func:`addDOHLocal` or the :func:`addTLSLocal` functions.
1185 :param string pathToServerCertificate: Path to a file containing the certificate used by the server.
1186 :param string pathToCACertificate: Path to a file containing the certificate of the certification authority that was used to sign the server certificate.
1187 :param string pathToCAPrivateKey: Path to a file containing the private key corresponding to the certification authority certificate.
1188 :param string outputFile: Path to a file where the resulting OCSP response will be written to.
1189 :param int numberOfDaysOfValidity: Number of days this OCSP response should be valid.
1190 :param int numberOfMinutesOfValidity: Number of minutes this OCSP response should be valid, in addition to the number of days.
1195 .. class:: DOHFrontend
1197 .. versionadded:: 1.4.0
1199 This object represents an address and port dnsdist is listening on for DNS over HTTPS queries.
1201 .. method:: DOHFrontend:loadTicketsKeys(ticketsKeysFile)
1203 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.
1205 :param str ticketsKeysFile: The path to a file from where TLS tickets keys should be loaded.
1207 .. method:: DOHFrontend:reloadCertificates()
1209 Reload the current TLS certificate and key pairs.
1211 .. method:: DOHFrontend:rotateTicketsKey()
1213 Replace the current TLS tickets key by a new random one.
1215 .. method:: DOHFrontend:setResponsesMap(rules)
1217 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.
1219 :param list of DOHResponseMapEntry objects rules: A list of DOHResponseMapEntry objects, obtained with :func:`newDOHResponseMapEntry`.
1222 .. function:: newDOHResponseMapEntry(regex, status, content [, headers]) -> DOHResponseMapEntry
1224 .. versionadded:: 1.4.0
1226 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.
1227 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.
1229 :param str regex: A regular expression to match the path against.
1230 :param int status: The HTTP code to answer with.
1231 :param str content: The content of the HTTP response, or a URL if the status is a redirection (3xx).
1232 :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`.
1237 .. class:: TLSContext
1239 .. versionadded:: 1.3.0
1241 This object represents an address and port dnsdist is listening on for DNS over TLS queries.
1243 .. method:: TLSContext:rotateTicketsKey()
1245 Replace the current TLS tickets key by a new random one.
1247 .. method:: TLSContext:loadTicketsKeys(ticketsKeysFile)
1249 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.
1251 :param str ticketsKeysFile: The path to a file from where TLS tickets keys should be loaded.
1256 .. class:: TLSFrontend
1258 .. versionadded:: 1.3.1
1260 This object represents the configuration of a listening frontend for DNS over TLS queries. To each frontend is associated a TLSContext.
1262 .. method:: TLSContext:loadNewCertificatesAndKeys(certFile(s), keyFile(s))
1264 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.
1266 :param str certFile(s): The path to a X.509 certificate file in PEM format, or a list of paths to such files.
1267 :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.
1269 EDNS on Self-generated answers
1270 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1272 There are several mechanisms in dnsdist that turn an existing query into an answer right away,
1273 without reaching out to the backend, including :func:`SpoofAction`, :func:`RCodeAction`, :func:`TCAction`
1274 and returning a response from ``Lua``. Those responses should, according to :rfc:`6891`, contain an ``OPT``
1275 record if the received request had one, which is the case by default and can be disabled using
1276 :func:`setAddEDNSToSelfGeneratedResponses`.
1278 We must, however, provide a responder's maximum payload size in this record, and we can't easily know the
1279 maximum payload size of the actual backend so we need to provide one. The default value is 1500 and can be
1280 overriden using :func:`setPayloadSizeOnSelfGeneratedAnswers`.
1282 .. function:: setAddEDNSToSelfGeneratedResponses(add)
1284 .. versionadded:: 1.3.3
1286 Whether to add EDNS to self-generated responses, provided that the initial query had EDNS.
1288 :param bool add: Whether to add EDNS, default is true.
1290 .. function:: setPayloadSizeOnSelfGeneratedAnswers(payloadSize)
1292 .. versionadded:: 1.3.3
1294 Set the UDP payload size advertised via EDNS on self-generated responses. In accordance with
1295 :rfc:`RFC 6891 <6891#section-6.2.5>`, values lower than 512 will be treated as equal to 512.
1297 :param int payloadSize: The responder's maximum UDP payload size, in bytes. Default is 1500.
1302 PowerDNS products can poll the security status of their respective versions. This polling, naturally,
1303 happens over DNS. If the result is that a given version has a security problem, the software will
1304 report this at level ‘Error’ during startup, and repeatedly during operations, every
1305 :func:`setSecurityPollInterval` seconds.
1307 By default, security polling happens on the domain ‘secpoll.powerdns.com’, but this can be changed with
1308 the :func:`setSecurityPollSuffix` function. If this setting is made empty, no polling will take place.
1309 Organizations wanting to host their own security zones can do so by changing this setting to a domain name
1310 under their control.
1312 To enable distributors of PowerDNS to signal that they have backported versions, the PACKAGEVERSION
1313 compilation-time macro can be used to set a distributor suffix.
1315 .. function:: setSecurityPollInterval(interval)
1317 .. versionadded:: 1.3.3
1319 Set the interval, in seconds, between two security pollings.
1321 :param int interval: The interval, in seconds, between two pollings. Default is 3600.
1323 .. function:: setSecurityPollSuffix(suffix)
1325 .. versionadded:: 1.3.3
1327 Domain name from which to query security update notifications. Setting this to an empty string disables secpoll.
1329 :param string suffix: The suffix to use, default is 'secpoll.powerdns.com.'.