Miniupnpd: update to 2.0
[tomato.git] / release / src / router / dnscrypt / README.markdown
blobd00bc43ea4b49b89dafd6ceba9a4fbe349006412
1 [![Build Status](https://travis-ci.org/jedisct1/dnscrypt-proxy.png?branch=master)](https://travis-ci.org/jedisct1/dnscrypt-proxy?branch=master)
3 [DNSCrypt](http://dnscrypt.org)
4 ===============================
6 A protocol for securing communications between a client and a DNS resolver.
8 Disclaimer
9 ----------
11 `dnscrypt-proxy` verifies that responses you get from a DNS provider have been
12 actually sent by that provider, and haven't been tampered with.
14 This is not a VPN. It doesn't mask your IP address, and if you are
15 using it with a public DNS service, be aware that it will (and has to)
16 decrypt your queries.
18 If you are using it for privacy, it might do the opposite of what you are
19 trying to achieve. It you are using it to prevent VPN "leaks", this
20 isn't the right tool either: the proper way to prevent VPN "leaks" is
21 to avoid sending data to yet another third party: use a VPN service that
22 operates its own DNS resolvers.
24 Description
25 -----------
27 `dnscrypt-proxy` provides local service which can be used directly as
28 your local resolver or as a DNS forwarder, authenticating requests
29 using the DNSCrypt protocol and passing them to an upstream server.
31 The DNSCrypt protocol uses high-speed high-security elliptic-curve
32 cryptography and is very similar to [DNSCurve](http://dnscurve.org/),
33 but focuses on securing communications between a client and its first-level
34 resolver.
36 While not providing end-to-end security, it protects the local
37 network, which is often the weakest point of the chain, against
38 man-in-the-middle attacks.
40 Download and integrity check
41 ----------------------------
43 dnscrypt-proxy can be downloaded here:
44 [dnscrypt-proxy download](http://download.dnscrypt.org/dnscrypt-proxy/)
46 Note: dnscrypt.org is now blocked by the Great Firewall of China. But
47 the site can be accessed at dnscrypt.bit instead (requires a resolver
48 with Namecoin support). Or if your current DNS resolver doesn't
49 support Namecoin yet, the source code can also be downloaded on
50 Github, in the "releases" section.
52 After having downloaded a file, compute its SHA256 digest. For example:
54     $ openssl dgst -sha256 dnscrypt-proxy-1.5.0.tar.bz2
56 Verify this digest against the expected one, that can be retrieved
57 using a simple DNS query:
59     $ drill -D TXT dnscrypt-proxy-1.5.0.tar.bz2.download.dnscrypt.org
63     $ dig +dnssec TXT dnscrypt-proxy-1.5.0.tar.bz2.download.dnscrypt.org
65 If the content of the TXT record doesn't match the SHA256 digest you
66 computed, please file a bug report on Github as soon as possible and
67 don't go any further.
69 Installation
70 ------------
72 The daemon is known to work on recent versions of OSX, OpenBSD,
73 Bitrig, NetBSD, Dragonfly BSD, FreeBSD, Linux, iOS (requires a
74 jailbroken device), Android (requires a rooted device), and
75 Windows (requires MingW).
77 Install [libsodium](https://github.com/jedisct1/libsodium).
78 On Linux, don't forget to run `ldconfig` if you installed it from
79 source.
81 A "minimal" build of libsodium (`--enable-minimal`) works equally well
82 as a full build with this proxy.
84 On Fedora, RHEL and CentOS, you may need to add `/usr/local/lib` to
85 the paths the dynamic linker is going to look at. Before issuing
86 `ldconfig`, type:
88     # echo /usr/local/lib > /etc/ld.so.conf.d/usr_local_lib.conf
90 Now, download the latest `dnscrypt-proxy` version and extract it:
92     $ bunzip2 -cd dnscrypt-proxy-*.tar.bz2 | tar xvf -
93     $ cd dnscrypt-proxy-*
95 Compile and install it using the standard procedure:
97     $ ./configure && make -j2
98     # make install
100 Replace `-j2` with whatever number of CPU cores you want to use for the
101 compilation process.
103 The proxy will be installed as `/usr/local/sbin/dnscrypt-proxy` by default.
105 Command-line switches are documented in the `dnscrypt-proxy(8)` man page.
107 *Note:* gcc 3.4.6 (and probably other similar versions) is known to
108 produce broken code on Mips targets with the -Os optimization level.
109 Use a different level (-O and -O2 are fine) or upgrade the compiler.
110 Thanks to Adrian Kotelba for reporting this.
112 GUIs for dnscrypt-proxy
113 -----------------------
115 If you need a simple graphical user interface in order to start/stop
116 the proxy and change your DNS settings, check out the following
117 project:
119 - [DNSCrypt WinClient](https://github.com/Noxwizard/dnscrypt-winclient):
120 Easily enable/disable DNSCrypt on multiple adapters. Supports
121 different ports and protocols, IPv6, parental controls and the proxy
122 can act as a gateway service. Windows only, written in .NET.
124 - [DNSCrypt Windows Service Manager](http://simonclausen.dk/projects/dnscrypt-winservicemgr/):
125 Assists in setting up DNSCrypt as a service, configure it and change network adapter DNS
126 settings to use DNSCrypt. It includes the option to use TCP/UDP protocol, IPV4/IPV6
127 connectivity, choice of network adapter to configure, as well as configurations for currently
128 available DNSCrypt providers.
130 - [DNSCrypt OSXClient](https://github.com/alterstep/dnscrypt-osxclient):
131 Mac OSX application to control the DNSCrypt Proxy.
133 - [DNSCrypt Tools for Linux](http://opendesktop.org/content/show.php/DNScrypt+Tools?content=164488):
134 A set of tools for `dnscrypt-proxy`. Features a start and stop button as well as options to enable
135 or disable from startup. Developed for Porteus Linux.
137 DNSCrypt-enabled resolvers
138 --------------------------
140 To get started, you can use any of the
141 [public DNS resolvers supporting DNSCrypt](https://github.com/jedisct1/dnscrypt-proxy/blob/master/dnscrypt-resolvers.csv).
143 This file is constantly updated, and its [minisign](https://jedisct1.github.io/minisign/)
144 [signature](https://raw.githubusercontent.com/jedisct1/dnscrypt-proxy/master/dnscrypt-resolvers.csv.minisig)
145 can be verified with the following command:
147     minisign -VP RWQf6LRCGA9i53mlYecO4IzT51TGPpvWucNSCh1CBM0QTaLn73Y7GFO3 -m dnscrypt-resolvers.csv
149 If you want to add DNSCrypt support to your own public or private
150 resolver, check out
151 [DNSCrypt-Wrapper](https://github.com/Cofyc/dnscrypt-wrapper), a
152 server-side dnscrypt proxy that works with any name resolver.
154 A [DNSCrypt server](https://github.com/jedisct1/dnscrypt-server-docker) Docker
155 image is also available to deploy a non-logging, DNSSEC and
156 DNSCrypt-capable resolver without having to manually compile or
157 configure anything.
159 Usage
160 -----
162 Having a dedicated system user, with no privileges and with an empty
163 home directory, is highly recommended. For extra security, DNSCrypt
164 will chroot() to this user's home directory and drop root privileges
165 for this user's uid as soon as possible.
167 The easiest way to start the daemon is:
169     # dnscrypt-proxy --daemonize --resolver-name=<resolver name>
171 Replace `<resolver name>` with the name of the resolver you want to
172 use (the first column in the list of public resolvers).
174 The proxy will accept incoming requests on 127.0.0.1, tag them with an
175 authentication code, forward them to the resolver, and validate each
176 answer before passing it to the client.
178 Given such a setup, in order to actually start using DNSCrypt, you
179 need to update your `/etc/resolv.conf` file and replace your current
180 set of resolvers with:
182     nameserver 127.0.0.1
184 Other common command-line switches include:
186 * `--daemonize` in order to run the server as a background process.
187 * `--local-address=<ip>[:port]` in order to locally bind a different IP
188 address than 127.0.0.1
189 * `--logfile=<file>` in order to write log data to a dedicated file. By
190 default, logs are sent to stdout if the server is running in foreground,
191 and to syslog if it is running in background.
192 * `--loglevel=<level>` if you need less verbosity in log files.
193 * `--max-active-requests=<count>` to set the maximum number of active
194 requests. The default value is 250.
195 * `--pidfile=<file>` in order to store the PID number to a file.
196 * `--user=<user name>` in order to chroot()/drop privileges.
197 * `--resolvers-list=<file>`: to specity the path to the CSV file containing
198 the list of available resolvers, and the parameters to use them.
199 * `--test` in order to check that the server-side proxy is properly
200 configured and that a valid certificate can be used. This is useful
201 for monitoring your own dnscrypt proxy. See the man page for more
202 information.
205 `--resolver-address=<ip>[:port]`,
206 `--provider-name=<certificate provider FQDN>`
207 and `--provider-key=<provider public key>` switches can be specified in
208 order to use a DNSCrypt-enabled recursive DNS service not listed in
209 the configuration file.
211 Running dnscrypt-proxy using systemd
212 ------------------------------------
214 On a system using systemd, and when compiled with `--with-systemd`,
215 the proxy can take advantage of systemd's socket activation instead of
216 creating the sockets itself. The proxy will also notify systemd on successful
217 startup.
219 Two sockets need to be configured: a UDP socket (`ListenStream`) and a
220 TCP socket (`ListenDatagram`) sharing the same port.
222 The source distribution includes the `dnscrypt-proxy.socket` and
223 `dnscrypt-proxy.service` files that can be used as a starting point.
225 Installation as a service (Windows only)
226 ----------------------------------------
228 The proxy can be installed as a Windows service.
231 [README-WINDOWS.markdown](https://github.com/jedisct1/dnscrypt-proxy/blob/master/README-WINDOWS.markdown)
232 for more information on DNSCrypt on Windows.
234 Using DNSCrypt in combination with a DNS cache
235 ----------------------------------------------
237 The DNSCrypt proxy is **not** a DNS cache. This means that incoming
238 queries will **not** be cached and every single query will require a
239 round-trip to the upstream resolver.
241 For optimal performance, the recommended way of running DNSCrypt is to
242 run it as a forwarder for a local DNS cache, like `unbound` or
243 `powerdns-recursor`.
245 Both can safely run on the same machine as long as they are listening
246 to different IP addresses (preferred) or different ports.
248 If your DNS cache is `unbound`, all you need is to edit the
249 `unbound.conf` file and add the following lines at the end of the `server`
250 section:
252     do-not-query-localhost: no
254     forward-zone:
255       name: "."
256       forward-addr: 127.0.0.1@40
258 The first line is not required if you are using different IP addresses
259 instead of different ports.
261 Then start `dnscrypt-proxy`, telling it to use a specific port (`40`, in
262 this example):
264     # dnscrypt-proxy --local-address=127.0.0.1:40 --daemonize
266 IPv6 support
267 ------------
269 IPv6 is fully supported. IPv6 addresses with a port number should be
270 specified as [ip]:port
272     # dnscrypt-proxy --local-address='[::1]:40' ...
274 Queries using nonstandard ports / over TCP
275 ------------------------------------------
277 Some routers and firewalls can block outgoing DNS queries or
278 transparently redirect them to their own resolver. This especially
279 happens on public Wifi hotspots, such as coffee shops.
281 As a workaround, the port number can be changed using
282 the `--resolver-port=<port>` option.
284 By default, `dnscrypt-proxy` sends outgoing queries to UDP port 443.
286 In addition, the DNSCrypt proxy can force outgoing queries to be
287 sent over TCP. For example, TCP port 443, which is commonly used for
288 communication over HTTPS, may not be filtered.
290 The `--tcp-only` command-line switch forces this behavior. When
291 an incoming query is received, the daemon immediately replies with a
292 "response truncated" message, forcing the client to retry over TCP.
293 The daemon then authenticates the query and forwards it over TCP
294 to the resolver.
296 `--tcp-only` is slower than UDP because multiple queries over a single
297 TCP connections aren't supported yet, and this workaround should
298 never be used except when bypassing a filter is actually required.
300 Public-key client authentication
301 --------------------------------
303 By default, dnscrypt-proxy generates non-deterministic client keys
304 every time it starts, or for every query (when the ephemeral keys
305 feature is turned on).
307 However, commercial DNS services may want to use DNSCrypt to
308 authenticate the sender of a query using public-key cryptography, i.e.
309 know what customer sent a query without altering the DNS query itself,
310 and without using shared secrets.
312 Resolvers that should be accessible from any IP address, but that are
313 supposed to be used only by specific users, can also take advantage of
314 DNSCrypt to only respond to queries sent using a given list of public keys.
316 In order to do so, dnscrypt-proxy 1.6.0 introduced the `--client-key`
317 (or `-K`) switch. This loads a secret client key from a file instead
318 of generating random keys:
320     # dnscrypt-proxy --client-key=/private/client-secret.key
322 This file has to remain private, and its content doesn't have to be
323 known by the DNS service provider.
325 Versions 1 and 2 of the DNSCrypt protocol use Curve25519 keys, and the
326 format of this file for Curve25519 keys is a hexadecimal string, with
327 optional :, [space] and - delimiters, decoding to 34 bytes:
329     01 01 || 32-byte Curve25519 secret key
331 EDNS payload size
332 -----------------
334 DNS packets sent over UDP have been historically limited to 512 bytes,
335 which is usually fine for queries, but sometimes a bit short for
336 replies.
338 Most modern authoritative servers, resolvers and stub resolvers
339 support the Extension Mechanism for DNS (EDNS) that, among other
340 things, allows a client to specify how large a reply over UDP can be.
342 Unfortunately, this feature is disabled by default on a lot of
343 operating systems. It has to be explicitly enabled, for example by
344 adding `options edns0` to the `/etc/resolv.conf` file on most
345 Unix-like operating systems.
347 `dnscrypt-proxy` can transparently rewrite outgoing packets before
348 authenticating them, in order to add the EDNS0 mechanism. By
349 default, a conservative payload size of 1252 bytes is advertised.
351 This size can be made larger by starting the proxy with the
352 `--edns-payload-size=<bytes>` command-line switch. Values up to 4096
353 are usually safe.
355 A value below or equal to 512 will disable this mechanism, unless a
356 client sends a packet with an OPT section providing a payload size.
358 The `hostip` utility
359 --------------------
361 The DNSCrypt proxy ships with a simple tool named `hostip` that
362 resolves a name to IPv4 or IPv6 addresses.
364 This tool can be useful for starting some services before
365 `dnscrypt-proxy`.
367 Queries made by `hostip` are not authenticated.
369 Plugins
370 -------
372 `dnscrypt-proxy` can be extended with plugins. A plugin acts as a
373 filter that can locally inspect and modify queries and responses.
375 The plugin API is documented in the `README-PLUGINS.markdown` file.
377 Any number of plugins can be combined (chained) by repeating the
378 `--plugin` command-line switch.
380 The default distribution ships with some example plugins:
382 * `libdcplugin_example_ldns_aaaa_blocking`: Directly return an empty
383 response to AAAA queries
385 Example usage:
387     # dnscrypt-proxy ... \
388     --plugin libdcplugin_example_ldns_aaaa_blocking.la
390 If IPv6 connectivity is not available on your network, this plugin
391 avoids waiting for responses about IPv6 addresses from upstream
392 resolvers. This can improve your web browsing experience.
394 * `libdcplugin_example_ldns_blocking`: Block specific domains and IP
395 addresses.
397 This plugin returns a REFUSED response if the query name is in a
398 list of blacklisted names, or if at least one of the returned
399 IP addresses happens to be in a list of blacklisted IPs.
401 Recognized switches are:
403     --domains=<file>
404     --ips=<file>
406 A file should list one entry per line.
408 IPv4 and IPv6 addresses are supported.
409 For names, leading and trailing wildcards (`*`) are also supported
410 (e.g. `*xxx*`, `*.example.com`, `ads.*`)
412     # dnscrypt-proxy ... \
413     --plugin libdcplugin_example,--ips=/etc/blk-ips,--domains=/etc/blk-names
415 * `libdcplugin_example-logging`: Log client queries
417 This plugin logs the client queries to the standard output (default)
418 or to a file.
420     # dnscrypt-proxy ... \
421     --plugin libdcplugin_example_logging,/var/log/dns.log
423 * Extra plugins
425 Additional plugins can be found on Github:
426 [Masquerade plugin](https://github.com/gchehab/dnscrypt-plugin-masquerade),
427 [GeoIP plugin](https://github.com/jedisct1/dnscrypt-plugin-geoip-block).