Commit f9c59b77 authored by Daniel Salzman's avatar Daniel Salzman

doc: move modules into separate module directories

parent 83b56d9a
......@@ -457,6 +457,40 @@ of the limitations will be hopefully removed in the near future.
- Legacy key export is not implemented.
- DS record export is not implemented.
.. _query-modules:
Query modules
=============
Knot DNS supports configurable query modules that can alter the way
queries are processed. Each query requires a finite number of steps to
be resolved. We call this set of steps a *query plan*, an abstraction
that groups these steps into several stages.
* Before-query processing
* Answer, Authority, Additional records packet sections processing
* After-query processing
For example, processing an Internet-class query needs to find an
answer. Then based on the previous state, it may also append an
authority SOA or provide additional records. Each of these actions
represents a 'processing step'. Now, if a query module is loaded for a
zone, it is provided with an implicit query plan which can be extended
by the module or even changed altogether.
A module is active if its name, which includes the ``mod-`` prefix, is assigned
to the zone/template :ref:`zone_module` option or to the *default* template
:ref:`template_global-module` option if activating for all queries.
If the module is configurable, a corresponding module section with
an identifier must be created and then referenced in the form of
``module_name/module_id``. See :ref:`Modules` for the list of available modules.
.. NOTE::
Query modules are processed in the order they are specified in the
zone/template configuration. In most cases, the recommended order is::
mod-synthrecord, mod-onlinesign, mod-rrl, mod-dnstap, mod-stats
Performance Tuning
==================
......
......@@ -10,10 +10,10 @@ Welcome to Knot DNS's documentation!
requirements
installation
configuration
modules
operation
troubleshooting
reference
modules
utilities
migration
appendices
......@@ -1110,545 +1110,6 @@ Minimum severity level for messages related to zones that are logged.
Minimum severity level for all message types that are logged.
.sp
\fIDefault:\fP not set
.SH MODULE RRL
.sp
A response rate limiting module.
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
mod\-rrl:
\- id: STR
rate\-limit: INT
slip: INT
table\-size: INT
whitelist: ADDR[/INT] | ADDR\-ADDR ...
.ft P
.fi
.UNINDENT
.UNINDENT
.SS id
.sp
A module identifier.
.SS rate\-limit
.sp
Rate limiting is based on the token bucket scheme. A rate basically
represents a number of tokens available each second. Each response is
processed and classified (based on several discriminators, e.g.
source netblock, query type, zone name, rcode, etc.). Classified responses are
then hashed and assigned to a bucket containing number of available
tokens, timestamp and metadata. When available tokens are exhausted,
response is dropped or sent as truncated (see \fI\%slip\fP).
Number of available tokens is recalculated each second.
.sp
\fIRequired\fP
.SS table\-size
.sp
Size of the hash table in a number of buckets. The larger the hash table, the lesser
the probability of a hash collision, but at the expense of additional memory costs.
Each bucket is estimated roughly to 32 bytes. The size should be selected as
a reasonably large prime due to better hash function distribution properties.
Hash table is internally chained and works well up to a fill rate of 90 %, general
rule of thumb is to select a prime near 1.2 * maximum_qps.
.sp
\fIDefault:\fP 393241
.SS slip
.sp
As attacks using DNS/UDP are usually based on a forged source address,
an attacker could deny services to the victim\(aqs netblock if all
responses would be completely blocked. The idea behind SLIP mechanism
is to send each N\s-2\uth\d\s0 response as truncated, thus allowing client to
reconnect via TCP for at least some degree of service. It is worth
noting, that some responses can\(aqt be truncated (e.g. SERVFAIL).
.INDENT 0.0
.IP \(bu 2
Setting the value to \fB0\fP will cause that all rate\-limited responses will
be dropped. The outbound bandwidth and packet rate will be strictly capped
by the \fI\%rate\-limit\fP option. All legitimate requestors affected
by the limit will face denial of service and will observe excessive timeouts.
Therefore this setting is not recommended.
.IP \(bu 2
Setting the value to \fB1\fP will cause that all rate\-limited responses will
be sent as truncated. The amplification factor of the attack will be reduced,
but the outbound data bandwidth won\(aqt be lower than the incoming bandwidth.
Also the outbound packet rate will be the same as without RRL.
.IP \(bu 2
Setting the value to \fB2\fP will cause that half of the rate\-limited responses
will be dropped, the other half will be sent as truncated. With this
configuration, both outbound bandwidth and packet rate will be lower than the
inbound. On the other hand, the dropped responses enlarge the time window
for possible cache poisoning attack on the resolver.
.IP \(bu 2
Setting the value to anything \fBlarger than 2\fP will keep on decreasing
the outgoing rate\-limited bandwidth, packet rate, and chances to notify
legitimate requestors to reconnect using TCP. These attributes are inversely
proportional to the configured value. Setting the value high is not advisable.
.UNINDENT
.sp
\fIDefault:\fP 1
.SS whitelist
.sp
A list of IP addresses, network subnets, or network ranges to exempt from
rate limiting. Empty list means that no incoming connection will be
white\-listed.
.sp
\fIDefault:\fP not set
.SH MODULE DNSTAP
.sp
The module dnstap allows query and response logging.
.sp
For all queries logging, use this module in the \fIdefault\fP template. For
zone\-specific logging, use this module in the proper zone configuration.
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
mod\-dnstap:
\- id: STR
sink: STR
identity: STR
version: STR
log\-queries: BOOL
log\-responses: BOOL
.ft P
.fi
.UNINDENT
.UNINDENT
.SS id
.sp
A module identifier.
.SS sink
.sp
A sink path, which can be either a file or a UNIX socket when prefixed with
\fBunix:\fP\&.
.sp
\fIRequired\fP
.SS identity
.sp
A DNS server identity. Set empty value to disable.
.sp
\fIDefault:\fP FQDN hostname
.SS version
.sp
A DNS server version. Set empty value to disable.
.sp
\fIDefault:\fP server version
.SS log\-queries
.sp
If enabled, query messages will be logged.
.sp
\fIDefault:\fP on
.SS log\-responses
.sp
If enabled, response messages will be logged.
.sp
\fIDefault:\fP on
.SH MODULE ONLINE-SIGN
.sp
The module provides online DNSSEC signing. Instead of pre\-computing the zone signatures
when the zone is loaded into the server or instead of loading an externally signed zone,
the signatures are computed on\-the\-fly during answering.
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
mod\-online\-sign:
\- id: STR
policy: STR
.ft P
.fi
.UNINDENT
.UNINDENT
.SS id
.sp
A module identifier.
.SS policy
.sp
A \fI\%reference\fP to DNSSEC signing policy. A special \fIdefault\fP
value can be used for the default policy settings.
.SH MODULE SYNTH-RECORD
.sp
This module is able to synthesize either forward or reverse records for the
given prefix and subnet.
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
mod\-synth\-record:
\- id: STR
type: forward | reverse
prefix: STR
origin: DNAME
ttl: INT
network: ADDR[/INT] | ADDR\-ADDR
.ft P
.fi
.UNINDENT
.UNINDENT
.SS id
.sp
A module identifier.
.SS type
.sp
The type of generated records.
.sp
Possible values:
.INDENT 0.0
.IP \(bu 2
\fBforward\fP – Forward records
.IP \(bu 2
\fBreverse\fP – Reverse records
.UNINDENT
.sp
\fIRequired\fP
.SS prefix
.sp
A record owner prefix.
.sp
\fBNOTE:\fP
.INDENT 0.0
.INDENT 3.5
The value doesn’t allow dots, address parts in the synthetic names are
separated with a dash.
.UNINDENT
.UNINDENT
.sp
\fIDefault:\fP empty
.SS origin
.sp
A zone origin (only valid for the \fI\%reverse type\fP).
.sp
\fIRequired\fP
.SS ttl
.sp
Time to live of the generated records.
.sp
\fIDefault:\fP 3600
.SS network
.sp
An IP address, a network subnet, or a network range the query must match.
.sp
\fIRequired\fP
.SH MODULE DNSPROXY
.sp
The module catches all unsatisfied queries and forwards them to the indicated
server for resolution.
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
mod\-dnsproxy:
\- id: STR
remote: remote_id
timeout: INT
fallback: BOOL
catch\-nxdomain: BOOL
.ft P
.fi
.UNINDENT
.UNINDENT
.SS id
.sp
A module identifier.
.SS remote
.sp
A \fI\%reference\fP to a remote server where the queries are
forwarded to.
.sp
\fIRequired\fP
.SS timeout
.sp
A remote response timeout in milliseconds.
.sp
\fIDefault:\fP 500
.SS fallback
.sp
If enabled, localy unsatisfied queries leading to REFUSED (no zone) are forwarded.
If disabled, all queries are directly forwarded without any local attempts
to resolve them.
.sp
\fIDefault:\fP on
.SS catch\-nxdomain
.sp
If enabled, localy unsatisfied queries leading to NXDOMAIN are forwarded.
This option is only relevant in the fallback mode.
.sp
\fIDefault:\fP off
.SH MODULE ROSEDB
.sp
The module provides a mean to override responses for certain queries before
the available zones are searched for the record.
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
mod\-rosedb:
\- id: STR
dbdir: STR
.ft P
.fi
.UNINDENT
.UNINDENT
.SS id
.sp
A module identifier.
.SS dbdir
.sp
A path to the directory where the database is stored.
.sp
\fIRequired\fP
.SH MODULE STATS
.sp
The module provides incoming query processing statistics.
.sp
\fBNOTE:\fP
.INDENT 0.0
.INDENT 3.5
Leading 16\-bit message size over TCP is not considered.
.UNINDENT
.UNINDENT
.INDENT 0.0
.INDENT 3.5
.sp
.nf
.ft C
mod\-stats:
\- id: STR
request\-protocol: BOOL
server\-operation: BOOL
request\-bytes: BOOL
response\-bytes: BOOL
edns\-presence: BOOL
flag\-presence: BOOL
response\-code: BOOL
reply\-nodata: BOOL
query\-type: BOOL
query\-size: BOOL
reply\-size: BOOL
.ft P
.fi
.UNINDENT
.UNINDENT
.SS id
.sp
A module identifier.
.SS request\-protocol
.sp
If enabled, all incoming requests are counted by the network protocol:
.INDENT 0.0
.IP \(bu 2
udp4 \- UDP over IPv4
.IP \(bu 2
tcp4 \- TCP over IPv4
.IP \(bu 2
udp6 \- UDP over IPv6
.IP \(bu 2
tcp6 \- TCP over IPv6
.UNINDENT
.sp
\fIDefault:\fP on
.SS server\-operation
.sp
If enabled, all incoming requests are counted by the server operation. The
server operation is based on message header OpCode and message query (meta) type:
.INDENT 0.0
.IP \(bu 2
query \- Normal query operation
.IP \(bu 2
update \- Dynamic update operation
.IP \(bu 2
notify \- NOTIFY request operation
.IP \(bu 2
axfr \- Full zone transfer operation
.IP \(bu 2
ixfr \- Incremental zone transfer operation
.IP \(bu 2
invalid \- Invalid server operation
.UNINDENT
.sp
\fIDefault:\fP on
.SS request\-bytes
.sp
If enabled, all incoming request bytes are counted by the server operation:
.INDENT 0.0
.IP \(bu 2
query \- Normal query bytes
.IP \(bu 2
update \- Dynamic update bytes
.IP \(bu 2
other \- Other request bytes
.UNINDENT
.sp
\fIDefault:\fP on
.SS response\-bytes
.sp
If enabled, outgoing response bytes are counted by the server operation:
.INDENT 0.0
.IP \(bu 2
reply \- Normal response bytes
.IP \(bu 2
transfer \- Zone transfer bytes
.IP \(bu 2
other \- Other response bytes
.UNINDENT
.sp
\fBWARNING:\fP
.INDENT 0.0
.INDENT 3.5
Dynamic update response bytes are not counted by this module.
.UNINDENT
.UNINDENT
.sp
\fIDefault:\fP on
.SS edns\-presence
.sp
If enabled, EDNS pseudo section presence is counted by the message direction:
.INDENT 0.0
.IP \(bu 2
request \- EDNS present in request
.IP \(bu 2
response \- EDNS present in response
.UNINDENT
.sp
\fIDefault:\fP off
.SS flag\-presence
.sp
If enabled, some message header flags are counted:
.INDENT 0.0
.IP \(bu 2
TC \- Truncated Answer in response
.IP \(bu 2
DO \- DNSSEC OK in request
.UNINDENT
.sp
\fIDefault:\fP off
.SS response\-code
.sp
If enabled, outgoing response code is counted:
.INDENT 0.0
.IP \(bu 2
NOERROR
.IP \(bu 2
\&...
.IP \(bu 2
NOTZONE
.IP \(bu 2
BADVERS
.IP \(bu 2
\&...
.IP \(bu 2
BADCOOKIE
.IP \(bu 2
other \- All other codes
.UNINDENT
.sp
\fBNOTE:\fP
.INDENT 0.0
.INDENT 3.5
In the case of multi\-message zone transfer response, just one counter is
incremented.
.UNINDENT
.UNINDENT
.sp
\fBWARNING:\fP
.INDENT 0.0
.INDENT 3.5
Dynamic update response code is not counted by this module.
.UNINDENT
.UNINDENT
.sp
\fIDefault:\fP on
.SS reply\-nodata
.sp
If enabled, NODATA pseudo RCODE (see RFC 2308, Section 2.2) is counted by the
query type:
.INDENT 0.0
.IP \(bu 2
A
.IP \(bu 2
AAAA
.IP \(bu 2
other \- All other types
.UNINDENT
.sp
\fIDefault:\fP off
.SS query\-type
.sp
If enabled, normal query type is counted:
.INDENT 0.0
.IP \(bu 2
A (TYPE1)
.IP \(bu 2
\&...
.IP \(bu 2
TYPE65
.IP \(bu 2
SPF (TYPE99)
.IP \(bu 2
\&...
.IP \(bu 2
TYPE110
.IP \(bu 2
ANY (TYPE255)
.IP \(bu 2
\&...
.IP \(bu 2
TYPE260
.IP \(bu 2
other \- All other types
.UNINDENT
.sp
\fBNOTE:\fP
.INDENT 0.0
.INDENT 3.5
Not all assigned meta types (IXFR, AXFR,...) have their own counters,
because such types are not processed as normal query.
.UNINDENT
.UNINDENT
.sp
\fIDefault:\fP off
.SS query\-size
.sp
If enabled, normal query message size distribution is counted by the size range
in bytes:
.INDENT 0.0
.IP \(bu 2
0\-15
.IP \(bu 2
16\-31
.IP \(bu 2
\&...
.IP \(bu 2
272\-287
.IP \(bu 2
288\-65535
.UNINDENT
.sp
\fIDefault:\fP off
.SS reply\-size
.sp
If enabled, normal reply message size distribution is counted by the size range
in bytes:
.INDENT 0.0
.IP \(bu 2
0\-15
.IP \(bu 2
16\-31
.IP \(bu 2
\&...
.IP \(bu 2
4080\-4095
.IP \(bu 2
4096\-65535
.UNINDENT
.sp
\fIDefault:\fP off
.SH AUTHOR
CZ.NIC Labs <http://www.knot-dns.cz>
.SH COPYRIGHT
......
.. highlight:: none
.. _Query_modules:
*************
Query modules
*************
Knot DNS supports configurable query modules that can alter the way
queries are processed. The concept is quite simple – each query
requires a finite number of steps to be resolved. We call this set of
steps a *query plan*, an abstraction that groups these steps into
several stages.
* Before-query processing
* Answer, Authority, Additional records packet sections processing
* After-query processing
For example, processing an Internet-class query needs to find an
answer. Then based on the previous state, it may also append an
authority SOA or provide additional records. Each of these actions
represents a 'processing step'. Now, if a query module is loaded for a
zone, it is provided with an implicit query plan which can be extended
by the module or even changed altogether.
A module is active if its name, which includes the ``mod-`` prefix, is assigned
to the zone/template :ref:`zone_module` option or to the *default* template
:ref:`template_global-module` option if activating for all queries.
If the module is configurable, a corresponding module section with
an identifier must be created and then referenced in the form of
``module_name/module_id``.
.. NOTE::
Query modules are processed in the order they are specified in the
zone/template configuration. In most cases, the recommended order is::
mod-synth-record, mod-online-sign, mod-rrl, mod-dnstap, mod-stats
``rrl`` — Response rate limiting
--------------------------------
Response rate limiting (RRL) is a method to combat DNS reflection amplification
attacks. These attacks rely on the fact that source address of a UDP query
can be forged, and without a worldwide deployment of `BCP38
<https://tools.ietf.org/html/bcp38>`_, such a forgery cannot be prevented.
An attacker can use a DNS server (or multiple servers) as an amplification
source and can flood a victim with a large number of unsolicited DNS responses.
The RRL lowers the amplification factor of these attacks by sending some of
the responses as truncated or by dropping them altogether.
The module introduces two counters. The number of slipped and dropped responses.
You can enable RRL by setting the :ref:`mod-rrl<mod-rrl>` module globally or per zone.
::
mod-rrl:
- id: default
rate-limit: 200 # Allow 200 resp/s for each flow
slip: 2 # Every other response slips
template:
- id: default
global-module: mod-rrl/default # Enable RRL globally
``dnstap`` – dnstap-enabled query logging
-----------------------------------------
A module for query and response logging based on dnstap_ library.
You can capture either all or zone-specific queries and responses; usually
you want to do the former. The configuration comprises only a
:ref:`mod-dnstap_sink` path parameter, which can be either a file or
a UNIX socket::
mod-dnstap: