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