xref: /netbsd-src/external/mpl/bind/dist/doc/dnssec-guide/validation.rst (revision 06dfa8449cb5e76c0044ec0f3badf7d5180af0f5)
1.. Copyright (C) Internet Systems Consortium, Inc. ("ISC")
2..
3.. SPDX-License-Identifier: MPL-2.0
4..
5.. This Source Code Form is subject to the terms of the Mozilla Public
6.. License, v. 2.0.  If a copy of the MPL was not distributed with this
7.. file, you can obtain one at https://mozilla.org/MPL/2.0/.
8..
9.. See the COPYRIGHT file distributed with this work for additional
10.. information regarding copyright ownership.
11
12.. _DNSSEC_validation:
13
14Validation
15----------
16
17.. _easy_start_guide_for_recursive_servers:
18
19Easy-Start Guide for Recursive Servers
20~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21
22This section provides the basic information needed to set up a
23working DNSSEC-aware recursive server, also known as a validating
24resolver. A validating resolver performs validation for each remote
25response received, following the chain of trust to verify that the answers it
26receives are legitimate, through the use of public key cryptography and
27hashing functions.
28
29.. _enabling_validation:
30
31Enabling DNSSEC Validation
32^^^^^^^^^^^^^^^^^^^^^^^^^^
33
34So how do we turn on DNSSEC validation? It turns out that you may not need
35to reconfigure your name server at all, since the most recent versions of BIND 9 -
36including packages and distributions - have shipped with DNSSEC validation
37enabled by default. Before making any configuration changes, check
38whether you already have DNSSEC validation enabled by following the steps
39described in :ref:`how_to_test_recursive_server`.
40
41In earlier versions of BIND, including 9.11-ESV, DNSSEC
42validation must be explicitly enabled. To do this, you only need to
43add one line to the ``options`` section of your configuration file:
44
45::
46
47   options {
48        ...
49        dnssec-validation auto;
50        ...
51    };
52
53Restart ``named`` or run ``rndc reconfig``, and your recursive server is
54now happily validating each DNS response. If this does not work for you,
55you may have some other network-related configurations that need to be
56adjusted. Take a look at :ref:`network_requirements` to make sure your network
57is ready for DNSSEC.
58
59.. _effect_of_enabling_validation:
60
61Effects of Enabling DNSSEC Validation
62^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
63
64Once DNSSEC validation is enabled, any DNS response that does not pass
65the validation checks results in a failure to resolve the domain name
66(often a SERVFAIL status seen by the client). If everything has
67been configured properly, this is the correct result; it means that an end user has
68been protected against a malicious attack.
69
70However, if there is a DNSSEC configuration issue (sometimes outside of
71the administrator's control), a specific name or sometimes entire
72domains may "disappear" from the DNS, and become unreachable
73through that resolver. For the end user, the issue may manifest itself
74as name resolution being slow or failing altogether; some parts of a URL
75not loading; or the web browser returning an error message indicating
76that the page cannot be displayed. For example, if root name
77servers were misconfigured with the wrong information about ``.org``, it
78could cause all validation for ``.org`` domains to fail. To end
79users, it would appear that all ``.org`` web
80sites were out of service [#]_. Should you encounter DNSSEC-related problems, don't be
81tempted to disable validation; there is almost certainly a solution that
82leaves validation enabled. A basic troubleshooting guide can be found in
83:ref:`dnssec_troubleshooting`.
84
85.. [#]
86   Of course, something like this could happen for reasons other than
87   DNSSEC: for example, the root publishing the wrong addresses for the
88   ``.org`` nameservers.
89
90.. _how_to_test_recursive_server:
91
92So You Think You Are Validating (How To Test A Recursive Server)
93~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
94
95Now that you have reconfigured your recursive server and
96restarted it, how do you know that your recursive name server is
97actually verifying each DNS query? There are several ways to check, and
98we've listed a few of them below.
99
100.. _using_web_based_tests_to_verify:
101
102Using Web-Based Tools to Verify
103^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
104
105For most people, the simplest way to check if a recursive name server
106is indeed validating DNS queries is to use one of the many web-based
107tools available.
108
109Configure your client computer to use the newly reconfigured recursive
110server for DNS resolution; then use one of these web-based tests to
111confirm that it is in fact validating DNS responses.
112
113-  `Internet.nl <https://en.conn.internet.nl/connection/>`__
114
115-  `DNSSEC Resolver Test (uni-due.de) <https://dnssec.vs.uni-due.de/>`__
116
117-  `DNSSEC or Not (VeriSign) <https://www.dnssec-or-not.com/>`__
118
119.. _using_dig_to_verify:
120
121Using ``dig`` to Verify
122^^^^^^^^^^^^^^^^^^^^^^^
123
124Web-based DNSSEC-verification tools often employ JavaScript. If you don't trust the
125JavaScript magic that the web-based tools rely on, you can take matters
126into your own hands and use a command-line DNS tool to check your
127validating resolver yourself.
128
129While ``nslookup`` is popular, partly because it comes pre-installed on
130most systems, it is not DNSSEC-aware. ``dig``, on the other hand, fully
131supports the DNSSEC standard and comes as a part of BIND. If you do not
132have ``dig`` already installed on your system, install it by downloading
133it from ISC's `website <https://www.isc.org/download>`__. ISC provides pre-compiled
134Windows versions on its website.
135
136``dig`` is a flexible tool for interrogating DNS name servers. It
137performs DNS lookups and displays the answers that are returned from the
138name servers that were queried. Most seasoned DNS administrators use
139``dig`` to troubleshoot DNS problems because of its flexibility, ease of
140use, and clarity of output.
141
142The example below shows how to use ``dig`` to query the name server 10.53.0.1
143for the A record for ``ftp.isc.org`` when DNSSEC validation is enabled
144(i.e. the default). The address 10.53.0.1 is only used as an example;
145replace it with the actual address or host name of your
146recursive name server.
147
148::
149
150   $ dig @10.53.0.1 ftp.isc.org. A +dnssec +multiline
151
152   ; <<>> DiG 9.16.0 <<>> @10.53.0.1 ftp.isc.org a +dnssec +multiline
153   ; (1 server found)
154   ;; global options: +cmd
155   ;; Got answer:
156   ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48742
157   ;; flags: qr rd ra ad; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
158
159   ;; OPT PSEUDOSECTION:
160   ; EDNS: version: 0, flags: do; udp: 4096
161   ; COOKIE: 29a9705c2160b08c010000005e67a4a102b9ae079c1b24c8 (good)
162   ;; QUESTION SECTION:
163   ;ftp.isc.org.       IN A
164
165   ;; ANSWER SECTION:
166   ftp.isc.org.        300 IN A 149.20.1.49
167   ftp.isc.org.        300 IN RRSIG A 13 3 300 (
168                   20200401191851 20200302184340 27566 isc.org.
169                   e9Vkb6/6aHMQk/t23Im71ioiDUhB06sncsduoW9+Asl4
170                   L3TZtpLvZ5+zudTJC2coI4D/D9AXte1cD6FV6iS6PQ== )
171
172   ;; Query time: 452 msec
173   ;; SERVER: 10.53.0.1#53(10.53.0.1)
174   ;; WHEN: Tue Mar 10 14:30:57 GMT 2020
175   ;; MSG SIZE  rcvd: 187
176
177The important detail in this output is the presence of the ``ad`` flag
178in the header. This signifies that BIND has retrieved all related DNSSEC
179information related to the target of the query (``ftp.isc.org``) and that
180the answer received has passed the validation process described in
181:ref:`how_are_answers_verified`. We can have confidence in the
182authenticity and integrity of the answer, that ``ftp.isc.org`` really
183points to the IP address 149.20.1.49, and that it was not a spoofed answer
184from a clever attacker.
185
186Unlike earlier versions of BIND, the current versions of BIND always
187request DNSSEC records (by setting the ``do`` bit in the query they make
188to upstream servers), regardless of DNSSEC settings. However, with
189validation disabled, the returned signature is not checked. This can be
190seen by explicitly disabling DNSSEC validation. To do this, add the line
191``dnssec-validation no;`` to the "options" section of the configuration
192file, i.e.:
193
194::
195
196   options {
197       ...
198       dnssec-validation no;
199       ...
200   };
201
202If the server is restarted (to ensure a clean cache) and the same
203``dig`` command executed, the result is very similar:
204
205::
206
207   $ dig @10.53.0.1 ftp.isc.org. A +dnssec +multiline
208
209   ; <<>> DiG 9.16.0 <<>> @10.53.0.1 ftp.isc.org a +dnssec +multiline
210   ; (1 server found)
211   ;; global options: +cmd
212   ;; Got answer:
213   ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39050
214   ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
215
216   ;; OPT PSEUDOSECTION:
217   ; EDNS: version: 0, flags: do; udp: 4096
218   ; COOKIE: a8dc9d1b9ec45e75010000005e67a8a69399741fdbe126f2 (good)
219   ;; QUESTION SECTION:
220   ;ftp.isc.org.       IN A
221
222   ;; ANSWER SECTION:
223   ftp.isc.org.        300 IN A 149.20.1.49
224   ftp.isc.org.        300 IN RRSIG A 13 3 300 (
225                   20200401191851 20200302184340 27566 isc.org.
226                   e9Vkb6/6aHMQk/t23Im71ioiDUhB06sncsduoW9+Asl4
227                   L3TZtpLvZ5+zudTJC2coI4D/D9AXte1cD6FV6iS6PQ== )
228
229   ;; Query time: 261 msec
230   ;; SERVER: 10.53.0.1#53(10.53.0.1)
231   ;; WHEN: Tue Mar 10 14:48:06 GMT 2020
232   ;; MSG SIZE  rcvd: 187
233
234However, this time there is no ``ad`` flag in the header. Although
235``dig`` is still returning the DNSSEC-related resource records, it is
236not checking them, and thus cannot vouch for the authenticity of the answer.
237If you do carry out this test, remember to re-enable DNSSEC validation
238(by removing the ``dnssec-validation no;`` line from the configuration
239file) before continuing.
240
241.. _verifying_protection_from_bad_domains:
242
243Verifying Protection From Bad Domain Names
244~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
245
246It is also important to make sure that DNSSEC is protecting your network from
247domain names that fail to validate; such failures could be caused by
248attacks on your system, attempting to get it to accept false DNS
249information. Validation could fail for a number of reasons: maybe the
250answer doesn't verify because it's a spoofed response; maybe the
251signature was a replayed network attack that has expired; or maybe the
252child zone has been compromised along with its keys, and the parent
253zone's information tells us that things don't add up. There is a
254domain name specifically set up to fail DNSSEC validation,
255``www.dnssec-failed.org``.
256
257With DNSSEC validation enabled (the default), an attempt to look up that
258name fails:
259
260::
261
262   $ dig @10.53.0.1 www.dnssec-failed.org. A
263
264   ; <<>> DiG 9.16.0 <<>> @10.53.0.1 www.dnssec-failed.org. A
265   ; (1 server found)
266   ;; global options: +cmd
267   ;; Got answer:
268   ;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 22667
269   ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
270
271   ;; OPT PSEUDOSECTION:
272   ; EDNS: version: 0, flags:; udp: 4096
273   ; COOKIE: 69c3083144854587010000005e67bb57f5f90ff2688e455d (good)
274   ;; QUESTION SECTION:
275   ;www.dnssec-failed.org.     IN  A
276
277   ;; Query time: 2763 msec
278   ;; SERVER: 10.53.0.1#53(10.53.0.1)
279   ;; WHEN: Tue Mar 10 16:07:51 GMT 2020
280   ;; MSG SIZE  rcvd: 78
281
282On the other hand, if DNSSEC validation is disabled (by adding the
283statement ``dnssec-validation no;`` to the ``options`` clause in the
284configuration file), the lookup succeeds:
285
286::
287
288   $ dig @10.53.0.1 www.dnssec-failed.org. A
289
290   ; <<>> DiG 9.16.0 <<>> @10.53.0.1 www.dnssec-failed.org. A
291   ; (1 server found)
292   ;; global options: +cmd
293   ;; Got answer:
294   ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 54704
295   ;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
296
297   ;; OPT PSEUDOSECTION:
298   ; EDNS: version: 0, flags:; udp: 4096
299   ; COOKIE: 251eee58208917f9010000005e67bb6829f6dabc5ae6b7b9 (good)
300   ;; QUESTION SECTION:
301   ;www.dnssec-failed.org.     IN  A
302
303   ;; ANSWER SECTION:
304   www.dnssec-failed.org.  7200    IN  A   68.87.109.242
305   www.dnssec-failed.org.  7200    IN  A   69.252.193.191
306
307   ;; Query time: 439 msec
308   ;; SERVER: 10.53.0.1#53(10.53.0.1)
309   ;; WHEN: Tue Mar 10 16:08:08 GMT 2020
310   ;; MSG SIZE  rcvd: 110
311
312Do not be tempted to disable DNSSEC validation just because some names
313are failing to resolve. Remember, DNSSEC protects your DNS lookup from
314hacking. The next section describes how to quickly check whether
315the failure to successfully look up a name is due to a validation
316failure.
317
318.. _how_do_i_know_validation_problem:
319
320How Do I Know I Have a Validation Problem?
321^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
322
323Since all DNSSEC validation failures result in a general ``SERVFAIL``
324message, how do we know if it was really a validation error?
325Fortunately, there is a flag in ``dig``, (``+cd``, for "checking
326disabled") which tells the server to disable DNSSEC validation. If
327you receive a ``SERVFAIL`` message, re-run the query a second time
328and set the ``+cd`` flag. If the query succeeds with ``+cd``, but
329ends in ``SERVFAIL`` without it, you know you are dealing with a
330validation problem. So using the previous example of
331``www.dnssec-failed.org`` and with DNSSEC validation enabled in the
332resolver:
333
334::
335
336   $ dig @10.53.0.1 www.dnssec-failed.org A +cd
337
338   ; <<>> DiG 9.16.0 <<>> @10.53.0.1 www.dnssec-failed.org. A +cd
339   ; (1 server found)
340   ;; global options: +cmd
341   ;; Got answer:
342   ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62313
343   ;; flags: qr rd ra cd; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
344
345   ;; OPT PSEUDOSECTION:
346   ; EDNS: version: 0, flags:; udp: 4096
347   ; COOKIE: 73ca1be3a74dd2cf010000005e67c8c8e6df64b519cd87fd (good)
348   ;; QUESTION SECTION:
349   ;www.dnssec-failed.org.     IN  A
350
351   ;; ANSWER SECTION:
352   www.dnssec-failed.org.  7197    IN  A   68.87.109.242
353   www.dnssec-failed.org.  7197    IN  A   69.252.193.191
354
355   ;; Query time: 0 msec
356   ;; SERVER: 10.53.0.1#53(10.53.0.1)
357   ;; WHEN: Tue Mar 10 17:05:12 GMT 2020
358   ;; MSG SIZE  rcvd: 110
359
360For more information on troubleshooting, please see
361:ref:`dnssec_troubleshooting`.
362
363.. _validation_easy_start_explained:
364
365Validation Easy Start Explained
366~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
367
368In :ref:`easy_start_guide_for_recursive_servers`, we used one line
369of configuration to turn on DNSSEC validation: the act of chasing down
370signatures and keys, making sure they are authentic. Now we are going to
371take a closer look at what DNSSEC validation actually does, and some other options.
372
373.. _dnssec_validation_explained:
374
375``dnssec-validation``
376^^^^^^^^^^^^^^^^^^^^^
377
378::
379
380   options {
381       dnssec-validation auto;
382   };
383
384This “auto” line enables automatic DNSSEC trust anchor configuration
385using the ``managed-keys`` feature. In this case, no manual key
386configuration is needed. There are three possible choices for the
387``dnssec-validation`` option:
388
389-  *yes*: DNSSEC validation is enabled, but a trust anchor must be
390   manually configured. No validation actually takes place until
391   at least one trusted key has been manually configured.
392
393-  *no*: DNSSEC validation is disabled, and the recursive server behaves
394   in the "old-fashioned" way of performing insecure DNS lookups.
395
396-  *auto*: DNSSEC validation is enabled, and a default trust anchor
397   (included as part of BIND 9) for the DNS root zone is used. This is the
398   default; BIND automatically does this if there is no
399   ``dnssec-validation`` line in the configuration file.
400
401Let's discuss the difference between *yes* and *auto*. If set to
402*yes*, the trust anchor must be manually defined and maintained
403using the ``trust-anchors`` statement (with either the ``static-key`` or
404``static-ds`` modifier) in the configuration file; if set to
405*auto* (the default, and as shown in the example), then no further
406action should be required as BIND includes a copy [#]_ of the root key.
407When set to *auto*, BIND automatically keeps the keys (also known as
408trust anchors, discussed in :ref:`trust_anchors_description`)
409up-to-date without intervention from the DNS administrator.
410
411We recommend using the default *auto* unless there is a good reason to
412require a manual trust anchor. To learn more about trust anchors,
413please refer to :ref:`trusted_keys_and_managed_keys`.
414
415.. _how_does_dnssec_change_dns_lookup_revisited:
416
417How Does DNSSEC Change DNS Lookup (Revisited)?
418^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
419
420Now you've enabled validation on your recursive name server and
421verified that it works. What exactly changed? In
422:ref:`how_does_dnssec_change_dns_lookup` we looked at a very
423high-level, simplified version of the 12 steps of the DNSSEC validation process. Let's revisit
424that process now and see what your validating resolver is doing in more
425detail. Again, as an example we are looking up the A record for the
426domain name ``www.isc.org`` (see :ref:`dnssec_12_steps`):
427
4281.  The validating resolver queries the ``isc.org`` name servers for the
429    A record of ``www.isc.org``. This query has the ``DNSSEC
430    OK`` (``do``) bit set to 1, notifying the remote authoritative
431    server that DNSSEC answers are desired.
432
4332.  Since the zone ``isc.org`` is signed, and its name servers are
434    DNSSEC-aware, it responds with the answer to the A record query plus
435    the RRSIG for the A record.
436
4373.  The validating resolver queries for the DNSKEY for ``isc.org``.
438
4394.  The ``isc.org`` name server responds with the DNSKEY and RRSIG
440    records. The DNSKEY is used to verify the answers received in #2.
441
4425.  The validating resolver queries the parent (``.org``) for the DS
443    record for ``isc.org``.
444
4456.  The ``.org`` name server is also DNSSEC-aware, so it responds with the
446    DS and RRSIG records. The DS record is used to verify the answers
447    received in #4.
448
4497.  The validating resolver queries for the DNSKEY for ``.org``.
450
4518.  The ``.org`` name server responds with its DNSKEY and RRSIG. The DNSKEY
452    is used to verify the answers received in #6.
453
4549.  The validating resolver queries the parent (root) for the DS record
455    for ``.org``.
456
45710. The root name server, being DNSSEC-aware, responds with DS and RRSIG
458    records. The DS record is used to verify the answers received in #8.
459
46011. The validating resolver queries for the DNSKEY for root.
461
46212. The root name server responds with its DNSKEY and RRSIG. The DNSKEY is
463    used to verify the answers received in #10.
464
465After step #12, the validating resolver takes the DNSKEY received and
466compares it to the key or keys it has configured, to decide whether
467the received key can be trusted. We talk about these locally
468configured keys, or trust anchors, in :ref:`trust_anchors_description`.
469
470With DNSSEC, every response includes not just the
471answer, but a digital signature (RRSIG) as well, so the
472validating resolver can verify the answer received. That is what we
473look at in the next section, :ref:`how_are_answers_verified`.
474
475.. _how_are_answers_verified:
476
477How Are Answers Verified?
478^^^^^^^^^^^^^^^^^^^^^^^^^
479
480.. note::
481
482   Keep in mind, as you read this section, that although words like
483   "encryption" and "decryption"
484   are used here from time to time, DNSSEC does not provide privacy.
485   Public key cryptography is used to verify data *authenticity* (who
486   sent it) and data *integrity* (it did not change during transit), but
487   any eavesdropper can still see DNS requests and responses in
488   clear text, even when DNSSEC is enabled.
489
490So how exactly are DNSSEC answers verified? Let's first see how verifiable information is
491generated. On the authoritative server, each DNS record (or message) is
492run through a hash function, and this hashed value is then encrypted by a
493private key. This encrypted hash value is the digital signature.
494
495.. figure:: ../dnssec-guide/img/signature-generation.png
496   :alt: Signature Generation
497   :width: 80.0%
498
499   Signature Generation
500
501When the validating resolver queries for the resource record, it
502receives both the plain-text message and the digital signature(s). The
503validating resolver knows the hash function used (it is listed in the digital
504signature record itself), so it can take the plain-text message and run
505it through the same hash function to produce a hashed value, which we'll call
506hash value X. The validating resolver can also obtain the public key
507(published as DNSKEY records), decrypt the digital signature, and get
508back the original hashed value produced by the authoritative server,
509which we'll call hash value Y. If hash values X and Y are identical, and
510the time is correct (more on what this means below), the answer is
511verified, meaning this answer came from the authoritative server
512(authenticity), and the content remained intact during transit
513(integrity).
514
515.. figure:: ../dnssec-guide/img/signature-verification.png
516   :alt: Signature Verification
517   :width: 80.0%
518
519   Signature Verification
520
521Take the A record ``ftp.isc.org``, for example. The plain text is:
522
523::
524
525   ftp.isc.org.     4 IN A  149.20.1.49
526
527The digital signature portion is:
528
529::
530
531   ftp.isc.org.      300 IN RRSIG A 13 3 300 (
532                   20200401191851 20200302184340 27566 isc.org.
533                   e9Vkb6/6aHMQk/t23Im71ioiDUhB06sncsduoW9+Asl4
534                   L3TZtpLvZ5+zudTJC2coI4D/D9AXte1cD6FV6iS6PQ== )
535
536When a validating resolver queries for the A record ``ftp.isc.org``, it
537receives both the A record and the RRSIG record. It runs the A record
538through a hash function (in this example, SHA256 as
539indicated by the number 13, signifying ECDSAP256SHA256) and produces
540hash value X. The resolver also fetches the appropriate DNSKEY record to
541decrypt the signature, and the result of the decryption is hash value Y.
542
543But wait, there's more! Just because X equals Y doesn't mean everything
544is good. We still have to look at the time. Remember we mentioned a
545little earlier that we need to check if the time is correct? Look
546at the two timestamps in our example above:
547
548-  Signature Expiration: 20200401191851
549
550-  Signature Inception: 20200302184340
551
552This tells us that this signature was generated UTC March 2nd, 2020, at
5536:43:40 PM (20200302184340), and it is good until UTC April 1st, 2020,
5547:18:51 PM (20200401191851). The validating resolver's current
555system time needs to fall between these two timestamps. If it does not, the
556validation fails, because it could be an attacker replaying an old
557captured answer set from the past, or feeding us a crafted one with
558incorrect future timestamps.
559
560If the answer passes both the hash value check and the timestamp check, it is
561validated and the authenticated data (``ad``) bit is set, and the response
562is sent to the client; if it does not verify, a SERVFAIL is returned to
563the client.
564
565.. [#]
566   BIND technically includes two copies of the root key: one is in
567   ``bind.keys.h`` and is built into the executable, and one is in
568   ``bind.keys`` as a ``trust-anchors`` statement. The two copies of the
569   key are identical.
570
571.. _trust_anchors_description:
572
573Trust Anchors
574~~~~~~~~~~~~~
575
576A trust anchor is a key that is placed into a validating resolver, so
577that the validator can verify the results of a given request with a
578known or trusted public key (the trust anchor). A validating resolver
579must have at least one trust anchor installed to perform DNSSEC
580validation.
581
582.. _how_trust_anchors_are_used:
583
584How Trust Anchors are Used
585~~~~~~~~~~~~~~~~~~~~~~~~~~
586
587In the section :ref:`how_does_dnssec_change_dns_lookup_revisited`,
588we walked through the 12 steps of the DNSSEC lookup process. At the end
589of the 12 steps, a critical comparison happens: the key received from
590the remote server and the key we have on file are compared to see if we
591trust it. The key we have on file is called a trust anchor, sometimes
592also known as a trust key, trust point, or secure entry point.
593
594The 12-step lookup process describes the DNSSEC lookup in the ideal
595world, where every single domain name is signed and properly delegated,
596and where each validating resolver only needs to have one trust anchor - that
597is, the root's public key. But there is no restriction that the
598validating resolver must only have one trust anchor. In fact, in the
599early stages of DNSSEC adoption, it was not unusual for a validating
600resolver to have more than one trust anchor.
601
602For instance, before the root zone was signed (in July 2010), some
603validating resolvers that wished to validate domain names in the ``.gov``
604zone needed to obtain and install the key for ``.gov``. A sample lookup
605process for ``www.fbi.gov`` at that time would have been eight steps rather
606than 12:
607
608.. figure:: ../dnssec-guide/img/dnssec-8-steps.png
609   :alt: DNSSEC Validation with ``.gov`` Trust Anchor
610
611
6121. The validating resolver queried ``fbi.gov`` name server for the A
613   record of ``www.fbi.gov``.
614
6152. The FBI's name server responded with the answer and its RRSIG.
616
6173. The validating resolver queried the FBI's name server for its DNSKEY.
618
6194. The FBI's name server responded with the DNSKEY and its RRSIG.
620
6215. The validating resolver queried a ``.gov`` name server for the DS
622   record of ``fbi.gov``.
623
6246. The ``.gov`` name server responded with the DS record and the
625   associated RRSIG for ``fbi.gov``.
626
6277. The validating resolver queried the ``.gov`` name server for its DNSKEY.
628
6298. The ``.gov`` name server responded with its DNSKEY and the associated
630   RRSIG.
631
632This all looks very similar, except it's shorter than the 12 steps that
633we saw earlier. Once the validating resolver receives the DNSKEY file in
634#8, it recognizes that this is the manually configured trusted key
635(trust anchor), and never goes to the root name servers to ask for the
636DS record for ``.gov``, or ask the root name servers for their DNSKEY.
637
638In fact, whenever the validating resolver receives a DNSKEY, it checks
639to see if this is a configured trusted key to decide whether it
640needs to continue chasing down the validation chain.
641
642.. _trusted_keys_and_managed_keys:
643
644Trusted Keys and Managed Keys
645^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
646
647Since the resolver is validating, we must have at least one key (trust
648anchor) configured. How did it get here, and how do we maintain it?
649
650If you followed the recommendation in
651:ref:`easy_start_guide_for_recursive_servers`, by setting
652``dnssec-validation`` to *auto*, there is nothing left to do.
653BIND already includes a copy of the root key (in the file
654``bind.keys``), and automatically updates it when the root key
655changes. [#]_ It looks something like this:
656
657::
658
659   trust-anchors {
660           # This key (20326) was published in the root zone in 2017.
661           . initial-key 257 3 8 "AwEAAaz/tAm8yTn4Mfeh5eyI96WSVexTBAvkMgJzkKTOiW1vkIbzxeF3
662                   +/4RgWOq7HrxRixHlFlExOLAJr5emLvN7SWXgnLh4+B5xQlNVz8Og8kv
663                   ArMtNROxVQuCaSnIDdD5LKyWbRd2n9WGe2R8PzgCmr3EgVLrjyBxWezF
664                   0jLHwVN8efS3rCj/EWgvIWgb9tarpVUDK/b58Da+sqqls3eNbuv7pr+e
665                   oZG+SrDK6nWeL3c6H5Apxz7LjVc1uTIdsIXxuOLYA4/ilBmSVIzuDWfd
666                   RUfhHdY6+cn8HFRm+2hM8AnXGXws9555KrUB5qihylGa8subX2Nn6UwN
667                   R1AkUTV74bU=";
668   };
669
670You can, of course, decide to manage this key manually yourself.
671First, you need to make sure that ``dnssec-validation`` is set
672to *yes* rather than *auto*:
673
674::
675
676   options {
677       dnssec-validation yes;
678   };
679
680Then, download the root key manually from a trustworthy source, such as
681`<https://www.isc.org/bind-keys>`__. Finally, take the root key you
682manually downloaded and put it into a ``trust-anchors`` statement as
683shown below:
684
685::
686
687   trust-anchors {
688           # This key (20326) was published in the root zone in 2017.
689           . static-key 257 3 8 "AwEAAaz/tAm8yTn4Mfeh5eyI96WSVexTBAvkMgJzkKTOiW1vkIbzxeF3
690                   +/4RgWOq7HrxRixHlFlExOLAJr5emLvN7SWXgnLh4+B5xQlNVz8Og8kv
691                   ArMtNROxVQuCaSnIDdD5LKyWbRd2n9WGe2R8PzgCmr3EgVLrjyBxWezF
692                   0jLHwVN8efS3rCj/EWgvIWgb9tarpVUDK/b58Da+sqqls3eNbuv7pr+e
693                   oZG+SrDK6nWeL3c6H5Apxz7LjVc1uTIdsIXxuOLYA4/ilBmSVIzuDWfd
694                   RUfhHdY6+cn8HFRm+2hM8AnXGXws9555KrUB5qihylGa8subX2Nn6UwN
695                   R1AkUTV74bU=";
696   };
697
698While this ``trust-anchors`` statement and the one in the ``bind.keys``
699file appear similar, the definition of the key in ``bind.keys`` has the
700``initial-key`` modifier, whereas in the statement in the configuration
701file, that is replaced by ``static-key``. There is an important
702difference between the two: a key defined with ``static-key`` is always
703trusted until it is deleted from the configuration file. With the
704``initial-key`` modified, keys are only trusted once: for as long as it
705takes to load the managed key database and start the key maintenance
706process. Thereafter, BIND uses the managed keys database
707(``managed-keys.bind.jnl``) as the source of key information.
708
709.. warning::
710
711   Remember, if you choose to manage the keys on your own, whenever the
712   key changes (which, for most zones, happens on a periodic basis),
713   the configuration needs to be updated manually. Failure to do so will
714   result in breaking nearly all DNS queries for the subdomain of the
715   key. So if you are manually managing ``.gov``, all domain names in
716   the ``.gov`` space may become unresolvable; if you are manually
717   managing the root key, you could break all DNS requests made to your
718   recursive name server.
719
720Explicit management of keys was common in the early days of DNSSEC, when
721neither the root zone nor many top-level domains were signed. Since
722then, `over 90% <https://stats.research.icann.org/dns/tld_report/>`__ of
723the top-level domains have been signed, including all the largest ones.
724Unless you have a particular need to manage keys yourself, it is best to
725use the BIND defaults and let the software manage the root key.
726
727.. [#]
728   The root zone was signed in July 2010 and, as at the time of this writing
729   (mid-2020), the key has been changed once, in October 2018. The intention going
730   forward is to roll the key once every five years.
731
732.. _whats_edns0_all_about:
733
734What's EDNS All About (And Why Should I Care)?
735~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
736
737.. _whats-edns0-all-about-overview:
738
739EDNS Overview
740^^^^^^^^^^^^^
741
742Traditional DNS responses are typically small in size (less than 512
743bytes) and fit nicely into a small UDP packet. The Extension mechanism
744for DNS (EDNS, or EDNS(0)) offers a mechanism to send DNS data in
745larger packets over UDP. To support EDNS, both the DNS server
746and the network need to be properly prepared to support the larger
747packet sizes and multiple fragments.
748
749This is important for DNSSEC, since the ``+do`` bit that signals
750DNSSEC-awareness is carried within EDNS, and DNSSEC responses are larger
751than traditional DNS ones. If DNS servers and the network environment cannot
752support large UDP packets, it will cause retransmission over TCP, or the
753larger UDP responses will be discarded. Users will likely experience
754slow DNS resolution or be unable to resolve certain names at all.
755
756Note that EDNS applies regardless of whether you are validating DNSSEC, because
757BIND has DNSSEC enabled by default.
758
759Please see :ref:`network_requirements` for more information on what
760DNSSEC expects from the network environment.
761
762.. _edns_on_dns_servers:
763
764EDNS on DNS Servers
765^^^^^^^^^^^^^^^^^^^
766
767For many years, BIND has had EDNS enabled by default,
768and the UDP packet size is set to a maximum of 4096 bytes. The DNS
769administrator should not need to perform any reconfiguration. You can
770use ``dig`` to verify that your server supports EDNS and see the UDP packet
771size it allows with this ``dig`` command:
772
773::
774
775   $ dig @10.53.0.1 www.isc.org. A +dnssec +multiline
776
777   ; <<>> DiG 9.16.0 <<>> @10.53.0.1 ftp.isc.org a +dnssec +multiline
778   ; (1 server found)
779   ;; global options: +cmd
780   ;; Got answer:
781   ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48742
782   ;; flags: qr rd ra ad; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
783
784   ;; OPT PSEUDOSECTION:
785   ; EDNS: version: 0, flags: do; udp: 4096
786   ; COOKIE: 29a9705c2160b08c010000005e67a4a102b9ae079c1b24c8 (good)
787   ;; QUESTION SECTION:
788   ;ftp.isc.org.       IN A
789
790   ;; ANSWER SECTION:
791   ftp.isc.org.        300 IN A 149.20.1.49
792   ftp.isc.org.        300 IN RRSIG A 13 3 300 (
793                   20200401191851 20200302184340 27566 isc.org.
794                   e9Vkb6/6aHMQk/t23Im71ioiDUhB06sncsduoW9+Asl4
795                   L3TZtpLvZ5+zudTJC2coI4D/D9AXte1cD6FV6iS6PQ== )
796
797   ;; Query time: 452 msec
798   ;; SERVER: 10.53.0.1#53(10.53.0.1)
799   ;; WHEN: Tue Mar 10 14:30:57 GMT 2020
800   ;; MSG SIZE  rcvd: 187
801
802There is a helpful testing tool available (provided by DNS-OARC) that
803you can use to verify resolver behavior regarding EDNS support:
804`<https://www.dns-oarc.net/oarc/services/replysizetest/>`__ .
805
806Once you've verified that your name servers have EDNS enabled, that should be the
807end of the story, right? Unfortunately, EDNS is a hop-by-hop extension
808to DNS. This means the use of EDNS is negotiated between each pair of
809hosts in a DNS resolution process, which in turn means if one of your
810upstream name servers (for instance, your ISP's recursive name server
811that your name server forwards to) does not support EDNS, you may experience DNS
812lookup failures or be unable to perform DNSSEC validation.
813
814.. _support_for_large_packets_network_equipment:
815
816Support for Large Packets on Network Equipment
817^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
818
819If both your recursive name server and your ISP's name servers
820support EDNS, we are all good here, right? Not so fast. Since these large
821packets have to traverse the network, the network infrastructure
822itself must allow them to pass.
823
824When data is physically transmitted over a network, it has to be broken
825down into chunks. The size of the data chunk is known as the Maximum
826Transmission Unit (MTU), and it can differ from network to
827network. IP fragmentation occurs when a large data packet needs to be
828broken down into chunks smaller than the
829MTU; these smaller chunks then need to be reassembled back into the large
830data packet at their destination. IP fragmentation is not necessarily a bad thing, and it most
831likely occurs on your network today.
832
833Some network equipment, such as a firewall, may make assumptions about
834DNS traffic. One of these assumptions may be how large each DNS packet
835is. When a firewall sees a larger DNS packet than it expects, it may either
836reject the large packet or drop its fragments because the firewall
837thinks it's an attack. This configuration probably didn't cause problems
838in the past, since traditional DNS packets are usually pretty small in
839size. However, with DNSSEC, these configurations need to be updated,
840since DNSSEC traffic regularly exceeds 1500 bytes (a common MTU value).
841If the configuration is not updated to support a larger DNS packet size,
842it often results in the larger packets being rejected, and to the
843end user it looks like the queries go unanswered. Or in the case of
844fragmentation, only a part of the answer makes it to the validating
845resolver, and your validating resolver may need to re-ask the question
846again and again, creating the appearance for end users that the DNS/network is slow.
847
848While you are updating the configuration on your network equipment, make
849sure TCP port 53 is also allowed for DNS traffic.
850
851.. _dns_uses_tcp:
852
853Wait... DNS Uses TCP?
854^^^^^^^^^^^^^^^^^^^^^
855
856Yes. DNS uses TCP port 53 as a fallback mechanism, when it cannot use
857UDP to transmit data. This has always been the case, even long before
858the arrival of DNSSEC. Traditional DNS relies on TCP port 53 for
859operations such as zone transfer. The use of DNSSEC, or DNS with IPv6
860records such as AAAA, increases the chance that DNS data will be
861transmitted via TCP.
862
863Due to the increased packet size, DNSSEC may fall back to TCP more often
864than traditional (insecure) DNS. If your network blocks or
865filters TCP port 53 today, you may already experience instability with
866DNS resolution, before even deploying DNSSEC.
867