Skip to content

Commit 1d02750

Browse files
committed
dnsdist: Add more YAML example to the documentation
1 parent d589085 commit 1d02750

18 files changed

+273
-18
lines changed

pdns/dnsdistdist/docs/guides/cache.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@ Something along the lines of a dozen bytes per pre-allocated entry can be expect
2525
That does not mean that the memory is completely allocated up-front, the final memory usage depending mostly on the size of cached responses and therefore varying during the cache's lifetime.
2626
Assuming an average response size of 512 bytes, a cache size of 10000000 entries on a 64-bit host with 8GB of dedicated RAM would be a safe choice.
2727

28+
The equivalent ``yaml`` configuration would be:
29+
30+
.. code-block:: yaml
31+
32+
packet-caches:
33+
- name: "pc"
34+
size: 1000
35+
max-ttl: 86400
36+
min-ttl: 0
37+
temporary-failure-ttl: 60
38+
state-ttl: 60
39+
dont-age: false
40+
pools:
41+
- name: ""
42+
packet-cache: "pc"
43+
2844
The :func:`setStaleCacheEntriesTTL` directive can be used to allow dnsdist to use expired entries from the cache when no backend is available.
2945
Only entries that have expired for less than n seconds will be used, and the returned TTL can be set when creating a new cache with :func:`newPacketCache`.
3046

pdns/dnsdistdist/docs/guides/carbon.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ To emit metrics to Graphite, or any other software supporting the Carbon protoco
1111
Where ``ourname`` can be used to override your hostname, and ``30`` is the reporting interval in seconds. ``dnsdist`` and ``main`` are used as namespace and instance variables. For querycount statistics these two variables are currently ignored. The last four arguments can be omitted.
1212
The latest version of `PowerDNS Metronome <https://github.com/ahupowerdns/metronome>`_ comes with attractive graphs for dnsdist by default.
1313

14+
The equivalent ``yaml`` configuration:
15+
16+
.. code-block:: yaml
17+
18+
metrics:
19+
carbon:
20+
- address: "ip-address-of-carbon-server"
21+
name: "ourname"
22+
interval: "30"
23+
namespace: "dnsdist"
24+
instance: "main"
25+
26+
1427
Query counters
1528
--------------
1629

pdns/dnsdistdist/docs/guides/console.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ The console can be enabled with :func:`controlSocket`:
1111
1212
controlSocket('192.0.2.53:5199')
1313
14+
Or in ``yaml``:
15+
16+
.. code-block:: yaml
17+
18+
console:
19+
listen-address: "192.0.2.53:5199"
20+
21+
1422
Enabling the console without encryption enabled is not recommended. Note that encryption requires building dnsdist with either libsodium or libcrypto support enabled.
1523

1624
Once you have a console-enabled dnsdist, the first step to enable encryption is to generate a key with :func:`makeKey`::
@@ -40,6 +48,12 @@ Then add the generated :func:`setKey` line to your dnsdist configuration file, a
4048
controlSocket('192.0.2.53:5199') -- Listen on this IP and port for client connections
4149
setKey("ENCODED KEY") -- Shared secret for the console
4250
51+
.. code-block:: yaml
52+
53+
console:
54+
listen-address: "192.0.2.53:5199"
55+
key: "ENCODED KEY"
56+
4357
Now you can run ``dnsdist -c`` to connect to the console.
4458
This makes dnsdist read its configuration file and use the :func:`controlSocket` and :func:`setKey` statements to set up its connection to the server.
4559

@@ -60,6 +74,15 @@ Since 1.3.0, dnsdist supports restricting which client can connect to the consol
6074
controlSocket('192.0.2.53:5199')
6175
setConsoleACL('192.0.2.0/24')
6276
77+
.. code-block:: yaml
78+
79+
console:
80+
listen-address: "192.0.2.53:5199"
81+
key: "ENCODED KEY"
82+
acl:
83+
- "192.0.2.0/24"
84+
85+
6386
The default value is '127.0.0.1', restricting the use of the console to local users. Please make sure that encryption is enabled
6487
before using :func:`addConsoleACL` or :func:`setConsoleACL` to allow connection from remote clients. Even if the console is
6588
restricted to local users, the use of encryption is still strongly advised to prevent unauthorized local users from connecting to

pdns/dnsdistdist/docs/guides/dns-over-http3.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ The fourth parameter, if present, indicates various options. For instance, you c
2121

2222
addDOH3Local('2001:db8:1:f00::1', '/etc/ssl/certs/example.com.pem', '/etc/ssl/private/example.com.key', {congestionControlAlgo="bbr"})
2323

24+
.. code-block:: yaml
25+
26+
binds:
27+
- listen-address: "2001:db8:1:f00::1"
28+
protocol: "DoH3"
29+
tls:
30+
certificates:
31+
- certificate: "/etc/ssl/certs/example.com.pem"
32+
key: "/etc/ssl/private/example.com.key"
33+
quic:
34+
congestion-control-algorithm: "bbr"
35+
36+
2437
A particular attention should be taken to the permissions of the certificate and key files. Many ACME clients used to get and renew certificates, like CertBot, set permissions assuming that services are started as root, which is no longer true for dnsdist as of 1.5.0. For that particular case, making a copy of the necessary files in the /etc/dnsdist directory is advised, using for example CertBot's ``--deploy-hook`` feature to copy the files with the right permissions after a renewal.
2538

2639
More information about sessions management can also be found in :doc:`../advanced/tls-sessions-management`.

pdns/dnsdistdist/docs/guides/dns-over-https.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,25 @@ A more complicated (and more realistic) example is when you want to indicate met
3434

3535
addDOHLocal('2001:db8:1:f00::1', '/etc/ssl/certs/example.com.pem', '/etc/ssl/private/example.com.key', "/", {customResponseHeaders={["link"]="<https://example.com/policy.html> rel=\\"service-meta\\"; type=\\"text/html\\""}})
3636

37+
Or in ``yaml``:
38+
39+
.. code-block:: yaml
40+
41+
- listen-address: "2001:db8:1:f00::1"
42+
protocol: "DoH"
43+
tls:
44+
certificates:
45+
- certificate: "/etc/ssl/certs/example.com.pem"
46+
key: "/etc/ssl/private/example.com.key"
47+
doh:
48+
provider: "nghttp2"
49+
paths:
50+
- "/"
51+
custom-response-headers:
52+
- key: "link"
53+
value: "<https://example.com/policy.html> rel=\\"service-meta\\"; type=\\"text/html\\""
54+
55+
3756
A particular attention should be taken to the permissions of the certificate and key files. Many ACME clients used to get and renew certificates, like CertBot, set permissions assuming that services are started as root, which is no longer true for dnsdist as of 1.5.0. For that particular case, making a copy of the necessary files in the /etc/dnsdist directory is advised, using for example CertBot's ``--deploy-hook`` feature to copy the files with the right permissions after a renewal.
3857

3958
More information about sessions management can also be found in :doc:`../advanced/tls-sessions-management`.
@@ -128,6 +147,18 @@ That support can be enabled via the ``dohPath`` parameter of the :func:`newServe
128147
129148
newServer({address="[2001:DB8::1]:443", tls="openssl", subjectName="doh.powerdns.com", dohPath="/dns-query", validateCertificates=true})
130149
150+
.. code-block:: yaml
151+
152+
backends:
153+
- address: "127.0.0.1:%d"
154+
protocol: "DoH"
155+
tls:
156+
provider: "openssl"
157+
validate-certificate: true
158+
subject-name: "doh.powerdns.com"
159+
doh:
160+
path: "/dns-query"
161+
131162
132163
Internal design
133164
^^^^^^^^^^^^^^^

pdns/dnsdistdist/docs/guides/dns-over-quic.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,19 @@ The fourth parameter, if present, indicates various options. For instance, you c
1818

1919
addDOQLocal('2001:db8:1:f00::1', '/etc/ssl/certs/example.com.pem', '/etc/ssl/private/example.com.key', {congestionControlAlgo="bbr"})
2020

21+
.. code-block:: yaml
22+
23+
binds:
24+
- listen-address: "2001:db8:1:f00::1"
25+
protocol: "DoQ"
26+
tls:
27+
certificates:
28+
- certificate: "/etc/ssl/certs/example.com.pem"
29+
key: "/etc/ssl/private/example.com.key"
30+
quic:
31+
congestion-control-algorithm: "bbr"
32+
33+
2134
A particular attention should be taken to the permissions of the certificate and key files. Many ACME clients used to get and renew certificates, like CertBot, set permissions assuming that services are started as root, which is no longer true for dnsdist as of 1.5.0. For that particular case, making a copy of the necessary files in the /etc/dnsdist directory is advised, using for example CertBot's ``--deploy-hook`` feature to copy the files with the right permissions after a renewal.
2235

2336
More information about sessions management can also be found in :doc:`../advanced/tls-sessions-management`.

pdns/dnsdistdist/docs/guides/dns-over-tls.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@ In order to support multiple certificates and keys, for example an ECDSA and an
1818

1919
addTLSLocal('192.0.2.55', {'/etc/ssl/certs/example.com.rsa.pem', '/etc/ssl/certs/example.com.ecdsa.pem'}, {'/etc/ssl/private/example.com.rsa.key', '/etc/ssl/private/example.com.ecdsa.key'})
2020

21+
.. code-block:: yaml
22+
23+
binds:
24+
- listen-address: "192.0.2.55"
25+
protocol: "DoT"
26+
tls:
27+
certificates:
28+
- certificate: "/etc/ssl/certs/example.com.rsa.pem"
29+
key: "/etc/ssl/private/example.com.rsa.key"
30+
- certificate: "/etc/ssl/certs/example.com.ecdsa.pem"
31+
key: "/etc/ssl/private/example.com.ecdsa.key"
32+
2133
The certificate chain presented by the server to an incoming client will then be selected based on the algorithms this client advertised support for.
2234

2335
A particular attention should be taken to the permissions of the certificate and key files. Many ACME clients used to get and renew certificates, like CertBot, set permissions assuming that services are started as root, which is no longer true for dnsdist as of 1.5.0. For that particular case, making a copy of the necessary files in the /etc/dnsdist directory is advised, using for example CertBot's ``--deploy-hook`` feature to copy the files with the right permissions after a renewal.
@@ -42,4 +54,3 @@ dnsdist provides a lot of counters to investigate issues:
4254

4355
* :func:`showTCPStats` will display a lot of information about current and passed connections
4456
* :func:`showTLSErrorCounters` some metrics about why TLS sessions failed to establish
45-

pdns/dnsdistdist/docs/guides/dnscrypt.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ To make :program:`dnsdist` listen to incoming DNSCrypt queries on 127.0.0.1 port
66

77
addDNSCryptBind("127.0.0.1:8443", "2.providername", "/path/to/resolver.cert", "/path/to/resolver.key")
88

9+
10+
And in ``yaml``:
11+
12+
.. code-block:: yaml
13+
14+
binds:
15+
- listen-address: "127.0.0.1:8443"
16+
protocol: "DNSCrypt"
17+
dnscrypt:
18+
provider-name: "2.providername"
19+
certificates:
20+
- certificate: "/path/to/resolver.cert"
21+
key: "/path/to/resolver.key"
22+
23+
924
To generate the provider and resolver certificates and keys, you can simply do::
1025

1126
> generateDNSCryptProviderKeys("/path/to/providerPublic.key", "/path/to/providerPrivate.key")

pdns/dnsdistdist/docs/guides/downstreams.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,20 @@ e.g.::
5656

5757
newServer({address="192.0.2.1", checkType="AAAA", checkClass=DNSClass.CHAOS, checkName="a.root-servers.net.", mustResolve=true})
5858

59+
In ``yaml``:
60+
61+
.. code-block:: yaml
62+
63+
backends:
64+
- address: "192.0.2.1"
65+
protocol: "Do53"
66+
health-checks:
67+
qname: "a.root-servers.net."
68+
qtype: "AAAA"
69+
qclass: "CHAOS"
70+
must-resolve: true
71+
72+
5973
You can turn on logging of health check errors using the :func:`setVerboseHealthChecks` function.
6074

6175
Lazy health-checking
@@ -86,6 +100,23 @@ So for example, if we set ``healthCheckMode`` to ``lazy``, ``lazyHealthCheckSamp
86100
87101
newServer({address="192.0.2.1", healthCheckMode='lazy', checkInterval=1, lazyHealthCheckFailedInterval=30, rise=2, maxCheckFailures=3, lazyHealthCheckThreshold=30, lazyHealthCheckSampleSize=100, lazyHealthCheckMinSampleCount=10, lazyHealthCheckMode='TimeoutOnly'})
88102
103+
.. code-block:: yaml
104+
105+
backends:
106+
- address: "192.0.2.1"
107+
protocol: "Do53"
108+
health-checks:
109+
mode: "lazy"
110+
rise: 2
111+
max-failures: 3
112+
check-interval: 1
113+
lazy:
114+
mode: "TimeoutOnly"
115+
interval: 30
116+
threshold: 30
117+
sample-size: 100
118+
min-sample-count: 10
119+
89120
The 'lazy' mode also supports using an exponential back-off time between health-check queries, once a backend has been moved to the 'down' state. This can be enabled by setting the ``lazyHealthCheckUseExponentialBackOff`` parameter to 'true'. Once the backend has been marked as 'down', the first query will be sent after ``lazyHealthCheckFailedInterval`` seconds, the second one after 2 times ``lazyHealthCheckFailedInterval`` seconds, the third after 4 times ``lazyHealthCheckFailedInterval`` seconds, and so on and so forth, until ``lazyHealthCheckMaxBackOff`` has been reached. Then probes will be sent every ``lazyHealthCheckMaxBackOff`` seconds (default is 3600 so one hour) until the backend comes 'up' again.
90121

91122
Source address selection
@@ -98,6 +129,13 @@ interface used by dnsdist to contact a downstream server. This can be done by us
98129
newServer({address="192.0.2.1", source="eth1"})
99130
newServer({address="192.0.2.1", source="192.0.2.127@eth1"})
100131

132+
.. code-block:: yaml
133+
134+
backends:
135+
- address: "192.0.2.1"
136+
protocol: "Do53"
137+
source: "192.0.2.127@eth1"
138+
101139
The supported values for source are:
102140

103141
- an IPv4 or IPv6 address, which must exist on the system

pdns/dnsdistdist/docs/guides/serverpools.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Server pools
22
------------
33

44
dnsdist has the concept to "server pools", any number of servers can belong to a group.
5-
A default pool, identified by the empty string ``''`` is always present, and `newServer` without a pool argument will assign the new server to that pool.
5+
A default pool, identified by the empty string ``''`` is always present, and :func:`newServer` without a pool argument will assign the new server to that pool.
66

77
Let's say we know we're getting a whole bunch of traffic for a domain used in DoS attacks, for example 'example.com'.
88
We can do two things with this kind of traffic.
@@ -42,4 +42,3 @@ Traffic exceeding the :term:`QPS` limit will not match that rule, and subsequent
4242
4343
getServer(4):addPool("abuse")
4444
getServer(4):rmPool("abuse")
45-

0 commit comments

Comments
 (0)