1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
|
.. SPDX-License-Identifier: GPL-3.0-or-later
.. _gettingstarted-config:
*************
Configuration
*************
The easiest way to configure Knot Resolver is via the ``/etc/knot-resolver/config.yaml`` file containing a declarative YAML configuration.
You can start exploring the configuration by reading further in this chapter, or you can take a look at the complete :ref:`configuration <configuration-chapter>` documentation.
.. contents::
:depth: 1
:local:
Complete example configuration files can be found `in Knot Resolver's source repository <https://gitlab.nic.cz/knot/knot-resolver/tree/master/etc/config>`_.
Examples are also installed as documentation files, typically in the ``/usr/share/doc/knot-resolver/examples/`` directory (the location may differ based on your Linux distribution).
.. tip::
The :ref:`kresctl <manager-client>` utility may be used to **validate** your configuration before you push it to the running resolver.
This can help prevent typos in the configuration from causing resolver outages.
.. code-block::
$ kresctl validate /etc/knot-resolver/config.yaml
If you update the configuration file while Knot Resolver is running, you can force the resolver to **reload** it by invoking a ``systemd`` reload command.
.. code-block::
$ systemctl reload knot-resolver.service
.. note::
**Reloading configuration** may fail, even when your configuration is valid, because some options cannot be changed while running.
You can always find an explanation of the error in the log accesed by the ``journalctl -eu knot-resolver`` command.
===============================
Listening on network interfaces
===============================
The first thing you will probably want to configure are the network interfaces to listen on.
The following example instructs the resolver to receive standard unencrypted DNS queries on IP addresses ``192.0.2.1`` and ``2001:db8::1``.
Encrypted DNS queries using the DNS-over-TLS protocol are accepted on all IP addresses of the ``eth0`` network interface, TCP port ``853``.
.. code-block:: yaml
network:
listen:
- interface: # port 53 is default
- 192.0.2.1
- 2001:db8::1
- interface: eth0
port: 853
kind: dot # DNS-over-TLS
For more details, see :ref:`network configuration <config-network>`.
.. warning::
On machines with multiple IP addresses, avoid listening on wildcards like
``0.0.0.0`` or ``::``. If a client can be reached through multiple addresses,
UDP answers from a wildcard address might pick a wrong source address - most
well-behaved clients will then refuse such a response.
.. _example-internal:
==========================
Example: Internal Resolver
==========================
This is an example configuration snippet typical for a company-internal resolver inaccessible from the outside of a company network.
^^^^^^^^^^^^^^^^^^^^^
Internal-only domains
^^^^^^^^^^^^^^^^^^^^^
An internal-only domain is a domain not accessible from the public Internet.
In order to resolve internal-only domains, a query policy needs to be added to forward queries to a correct internal server.
This configuration will forward the two listed domains to an internal authoritative DNS server with the IP address ``192.0.2.44``.
.. code-block:: yaml
forward:
# define a list of internal-only domains
- subtree:
- company.example
- internal.example
# forward all queries belonging to the domains in the list above to IP address '192.0.2.44'
servers:
- 192.0.2.44
# common options configuration for internal-only domains
options:
authoritative: true
dnssec: false
See the :ref:`forwarding <config-forward>` chapter for more details.
.. _example-isp:
=====================
Example: ISP Resolver
=====================
The following configuration snippets are typical for Internet Service Providers offering DNS resolver
services to their own clients on their own network. Please note that running a *public DNS resolver*
is a more complicated use-case and not covered by this example.
^^^^^^^^^^^^^^^^^^^^^^
Limiting client access
^^^^^^^^^^^^^^^^^^^^^^
With the exception of public resolvers, a DNS resolver should resolve only queries sent by clients in its own network. This restriction limits the attack surface on the resolver itself, as well as the rest of the Internet.
In a situation where access to your DNS resolver is not limited using an IP firewall, you may want to implement access restrictions.
The following example allows only queries from clients on the subnet ``192.0.2.0/24`` and refuses all the rest.
.. code-block:: yaml
views:
# refuse everything that hasn't matched
- subnets: [ 0.0.0.0/0, "::/0" ]
answer: refused
# whitelist queries identified by subnet
- subnets: [ 192.0.2.0/24 ]
answer: allow
^^^^^^^^^^^^^^^^^^^^^^^^
TLS server configuration
^^^^^^^^^^^^^^^^^^^^^^^^
Knot Resolver supports secure transport for DNS queries between client machines and the resolvers, a feature whose popular demand is on the rise.
The recommended way to achieve this is to start a DNS-over-TLS server and accept encrypted queries.
First step is to enable TLS on listening interfaces:
.. code-block:: yaml
network:
listen:
# DNS over TLS on port 853
- interface:
- 192.0.2.1
- 2001:db8::1
kind: dot
By default, a self-signed certificate is generated.
The second step is then obtaining and configuring your own TLS certificates signed by a trusted CA.
Once a certificate was obtained, a path to the certificate files can be specified as follows:
.. code-block:: yaml
network:
tls:
cert-file: '/etc/knot-resolver/server-cert.pem'
key-file: '/etc/knot-resolver/server-key.pem'
^^^^^^^^^^^^^^^^^^^^^^^^^
Mandatory domain blocking
^^^^^^^^^^^^^^^^^^^^^^^^^
Some jurisdictions mandate blocking access to certain domains.
This can be achieved using by using :option:`rules <rules: <list>>`.
.. code-block:: yaml
local-data:
rules:
- name:
- example.com.
- blocked.example.net.
subtree: nxdomain
.. _example-personal:
==========================
Example: Personal Resolver
==========================
DNS queries can be used to gather data about user behavior.
Knot Resolver can be configured to forward DNS queries elsewhere,
to protect the users from being eavesdropped on by using TLS encryption.
.. warning::
Latest research has proven that encrypting DNS traffic is not sufficient to protect the users' privacy.
Therefore, we recommend all users to use a full VPN instead of encrypting *just* DNS queries.
The following configuration is provided **only for users who are not able to encrypt all their traffic**.
For more information, please see the following articles:
- Simran Patil and Nikita Borisov. 2019. What can you learn from an IP? (`slides <https://irtf.org/anrw/2019/slides-anrw19-final44.pdf>`_, `the article itself <https://dl.acm.org/authorize?N687437>`_)
- `Bert Hubert. 2019. Centralised DoH is bad for Privacy, in 2019 and beyond <https://labs.ripe.net/Members/bert_hubert/centralised-doh-is-bad-for-privacy-in-2019-and-beyond>`_
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Forwarding over TLS protocol (DNS-over-TLS)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Forwarding over the TLS protocol protects DNS queries sent out by the resolver.
It can be configured using :ref:`forwarding <config-forward>`, which provides settings for authentication.
.. code-block:: yaml
forward:
# encrypted public resolver, for all names
- subtree: "."
servers:
- address:
- 2001:148f:fffe::1
- 193.17.47.1
transport: tls
hostname: odvr.nic.cz
.. tip::
See list of `DNS Privacy Test Servers`_ supporting DNS-over-TLS to test your configuration.
.. future
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Forwarding to multiple targets
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
With the use of slice function, it is possible to split the
.. With the use of :any:`policy.slice` function, it is possible to split the
entire DNS namespace into distinct "slices". When used in conjunction with
:ref:`TLS forwarding <tls-forwarding>`, it's possible to forward different queries to different
.. :ref:`policy.TLS_FORWARD <tls-forwarding>`, it's possible to forward different queries to different
remote resolvers. As a result no single remote resolver will get complete list
of all queries performed by this client.
.. warning::
Beware that this method has not been scientifically tested and there might be
types of attacks which will allow remote resolvers to infer more information about the client.
Again: If possible encrypt **all** your traffic and not just DNS queries!
.. code-block:: yaml
policy:
# TODO
.. code-block:: lua
policy.add(policy.slice(
policy.slice_randomize_psl(),
policy.TLS_FORWARD({{'192.0.2.1', hostname='res.example.com'}}),
policy.TLS_FORWARD({
-- multiple servers can be specified for a single slice
-- the one with lowest round-trip time will be used
{'193.17.47.1', hostname='odvr.nic.cz'},
{'185.43.135.1', hostname='odvr.nic.cz'},
})
))
^^^^^^^^^^^^^^^^^^^^
Non-persistent cache
^^^^^^^^^^^^^^^^^^^^
Knot Resolver's cache contains data its clients queried for.
If you are concerned about attackers who are able to get access to your
computer system in power-off state, and your storage device is not secured by
encryption, you can move the cache to tmpfs_.
See :ref:`config-cache-persistence`.
.. .. raw:: html
.. <h2>Next steps</h2>
.. Congratulations! Your resolver is now up and running and ready to accept queries. For
.. serious deployments, do not forget to read the chapters :ref:`configuration-chapter` and
.. :ref:`operation-chapter`.
.. _`DNS Privacy Test Servers`: https://dnsprivacy.org/wiki/display/DP/DNS+Privacy+Test+Servers
.. _tmpfs: https://en.wikipedia.org/wiki/Tmpfs
|