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: 13 14DNSSEC 15------ 16DNS Security Extensions (DNSSEC) provide reliable protection from 17`cache poisoning`_ attacks. At the same time these extensions also provide other benefits: 18they limit the impact of `random subdomain attacks`_ on resolver caches and authoritative 19servers, and provide the foundation for modern applications like `authenticated 20and private e-mail transfer`_. 21 22To achieve this goal, DNSSEC adds `digital signatures`_ to DNS records in 23authoritative DNS zones, and DNS resolvers verify the validity of the signatures on the 24received records. If the signatures match the received data, the resolver can 25be sure that the data was not modified in transit. 26 27.. note:: 28 DNSSEC and transport-level encryption are complementary! 29 Unlike typical transport-level encryption like DNS-over-TLS, DNS-over-HTTPS, 30 or VPN, DNSSEC makes DNS records verifiable at all points of the DNS 31 resolution chain. 32 33This section focuses on ways to deploy DNSSEC using BIND. For a more in-depth 34discussion of DNSSEC principles (e.g. :ref:`how_does_dnssec_change_dns_lookup`) 35please see :doc:`dnssec-guide`. 36 37.. _`cache poisoning`: https://en.wikipedia.org/wiki/DNS_cache_poisoning 38.. _`random subdomain attacks`: https://www.isc.org/blogs/nsec-caching-should-limit-excessive-queries-to-dns-root/ 39.. _`digital signatures`: https://en.wikipedia.org/wiki/Digital_signature 40.. _`authenticated and private e-mail transfer`: https://github.com/internetstandards/toolbox-wiki/blob/main/DANE-for-SMTP-how-to.md 41 42 43.. _dnssec_zone_signing: 44 45Zone Signing 46~~~~~~~~~~~~ 47 48BIND offers several ways to generate signatures and maintain their validity 49during the lifetime of a DNS zone: 50 51 - :ref:`dnssec_kasp` - **strongly recommended** 52 - :ref:`dnssec_dynamic_zones` - only for special needs 53 - :ref:`dnssec_tools` - discouraged, use only for debugging 54 55.. _zone_keys: 56 57Zone keys 58^^^^^^^^^ 59Regardless of the :ref:`zone-signing <dnssec_zone_signing>` method in use, cryptographic keys are 60stored in files named like :file:`Kdnssec.example.+013+12345.key` and 61:file:`Kdnssec.example.+013+12345.private`. 62The private key (in the ``.private`` file) is used to generate signatures, and 63the public key (in the ``.key`` file) is used for signature verification. 64Additionally, the :ref:`dnssec_kasp` method creates a third file, 65:file:`Kdnssec.example+013+12345.state`, which is used to track DNSSEC key timings 66and to perform key rollovers safely. 67 68These filenames contain: 69 70 - the key name, which always matches the zone name (``dnssec.example.``), 71 - the `algorithm number`_ (013 is ECDSAP256SHA256, 008 is RSASHA256, etc.), 72 - and the key tag, i.e. a non-unique key identifier (12345 in this case). 73 74.. _`algorithm number`: https://www.iana.org/assignments/dns-sec-alg-numbers/dns-sec-alg-numbers.xhtml#dns-sec-alg-numbers-1 75 76 77.. warning:: 78 Private keys are required for full disaster recovery. Back up key files in a 79 safe location and protect them from unauthorized access. Anyone with 80 access to the private key can create fake but seemingly valid DNS data. 81 82 83.. _dnssec_kasp: 84 85Fully Automated (Key and Signing Policy) 86^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 87 88Key and Signing Policy (KASP) is a method of configuration that describes 89how to maintain DNSSEC signing keys and how to sign the zone. 90 91This is the recommended, fully automated way to sign and maintain DNS zones. For 92most use cases users can simply use the built-in default policy, which applies 93up-to-date DNSSEC practices: 94 95.. code-block:: none 96 :emphasize-lines: 4 97 98 zone "dnssec.example" { 99 type primary; 100 file "dnssec.example.db"; 101 dnssec-policy default; 102 inline-signing yes; 103 }; 104 105The :any:`dnssec-policy` statement requires dynamic DNS to be set up, or 106:any:`inline-signing` to be enabled. In the example above we use the latter. 107 108This is sufficient to create the necessary signing keys, and generate 109``DNSKEY``, ``RRSIG``, and ``NSEC`` records for the zone. BIND also takes 110care of any DNSSEC maintenance for this zone, including replacing signatures 111that are about to expire and managing :ref:`key_rollovers`. 112 113.. note:: 114 :any:`dnssec-policy` needs write access to the zone. Please see 115 :any:`dnssec-policy` for more details about implications for zone storage. 116 117The default policy creates one key that is used to sign the complete zone, 118and uses ``NSEC`` to enable authenticated denial of existence (a secure way 119to tell which records do not exist in a zone). This policy is recommended 120and typically does not need to be changed. 121 122If needed, a custom policy can be defined by adding a :any:`dnssec-policy` statement 123into the configuration: 124 125.. code-block:: none 126 127 128 dnssec-policy "custom" { 129 dnskey-ttl 600; 130 keys { 131 ksk lifetime P1Y algorithm ecdsap384sha384; 132 zsk lifetime 60d algorithm ecdsap384sha384; 133 }; 134 nsec3param iterations 0 optout no salt-length 0; 135 }; 136 137This ``custom`` policy, for example: 138 139 - uses a very short ``DNSKEY`` TTL (600 seconds), 140 - uses two keys to sign the zone: a Key Signing Key (KSK) to sign the key 141 related RRsets (``DNSKEY``, ``CDS``, and ``CDNSKEY``), and a Zone Signing 142 Key (ZSK) to sign the rest of the zone. The KSK is automatically 143 rotated after one year and the ZSK after 60 days. 144 145Also: 146 - The configured keys have a lifetime set and use the ECDSAP384SHA384 147 algorithm. 148 - The last line instructs BIND to generate NSEC3 records for 149 :ref:`Proof of Non-Existence <advanced_discussions_proof_of_nonexistence>`, 150 using zero extra iterations and no salt. NSEC3 opt-out is disabled, meaning 151 insecure delegations also get an NSEC3 record. 152 153For more information about KASP configuration see :any:`dnssec-policy`. 154 155The :ref:`dnssec_advanced_discussions` section in the DNSSEC Guide discusses the 156various policy settings and may be useful for determining values for specific 157needs. 158 159Key Rollover 160============ 161 162When using a :any:`dnssec-policy`, a key lifetime can be set to trigger 163key rollovers. ZSK rollovers are fully automatic, but for KSK and CSK rollovers 164a DS record needs to be submitted to the parent. See 165:ref:`secure_delegation` for possible ways to do so. 166 167Once the DS is in the parent (and the DS of the predecessor key is withdrawn), 168BIND needs to be told that this event has happened. This can be done automatically 169by configuring parental agents: 170 171.. code-block:: none 172 :emphasize-lines: 5 173 174 zone "dnssec.example" { 175 type primary; 176 file "dnssec.example.db"; 177 dnssec-policy default; 178 inline-signing yes; 179 parental-agents { 192.0.2.1; }; 180 }; 181 182Here one server, ``192.0.2.1``, is configured for BIND to send DS queries to, 183to check the DS RRset for ``dnssec-example`` during key rollovers. This needs 184to be a trusted server, because BIND does not validate the response. 185 186If setting up a parental agent is undesirable, it is also possible to tell BIND that the 187DS is published in the parent with: 188:option:`rndc dnssec -checkds -key 12345 published dnssec.example. <rndc dnssec>`. 189and the DS for the predecessor key has been removed with: 190:option:`rndc dnssec -checkds -key 54321 withdrawn dnssec.example. <rndc dnssec>`. 191where 12345 and 54321 are the key tags of the successor and predecessor key, 192respectively. 193 194To roll a key sooner than scheduled, or to roll a key that 195has an unlimited lifetime, use: 196:option:`rndc dnssec -rollover -key 12345 dnssec.example. <rndc dnssec>`. 197 198To revert a signed zone back to an insecure zone, change 199the zone configuration to use the built-in "insecure" policy. Detailed 200instructions are described in :ref:`revert_to_unsigned`. 201 202.. _dnssec_dynamic_zones: 203 204Manual Key Management 205^^^^^^^^^^^^^^^^^^^^^ 206 207.. warning:: 208 The method described here allows full control over the keys used to sign 209 the zone. This is required only for very special cases and is generally 210 discouraged. Under normal circumstances, please use :ref:`dnssec_kasp`. 211 212 213.. _dnssec_dynamic_zones_multisigner_model: 214 215Multi-Signer Model 216================== 217 218Dynamic zones provide the ability to sign a zone by multiple providers, meaning 219each provider signs and serves the same zone independently. Such a setup requires 220some coordination between providers when it comes to key rollovers, and may be 221better suited to be configured with ``auto-dnssec allow;``. This permits keys to 222be updated and the zone to be re-signed only if the user issues the command 223:option:`rndc sign zonename <rndc sign>`. 224 225A zone can also be configured with ``auto-dnssec maintain``, which automatically 226adjusts the zone's DNSSEC keys on a schedule according to the key timing 227metadata. However, keys still need to be generated separately, for 228example with :iscman:`dnssec-keygen`. 229 230Of course, dynamic zones can also use :any:`dnssec-policy` to fully automate DNSSEC 231maintenance. The next sections assume that more key 232management control is needed, and describe how to use dynamic DNS update to perform 233various DNSSEC operations. 234 235.. _dnssec_dynamic_zones_enabling_dnssec: 236 237Enabling DNSSEC Manually 238======================== 239As an alternative to fully automated zone signing using :ref:`dnssec-policy 240<dnssec_kasp>`, a zone can be changed from insecure to secure using a dynamic 241DNS update. :iscman:`named` must be configured so that it can see the ``K*`` 242files which contain the public and private parts of the `zone keys`_ that are 243used to sign the zone. Key files should be placed in the :any:`key-directory`, as 244specified in :iscman:`named.conf`: 245 246:: 247 248 zone update.example { 249 type primary; 250 update-policy local; 251 auto-dnssec allow; 252 file "dynamic/update.example.db"; 253 key-directory "keys/update.example/"; 254 }; 255 256If there are both a KSK and a ZSK available (or a CSK), this configuration causes the 257zone to be signed. An ``NSEC`` chain is generated as part of the initial signing 258process. 259 260In any secure zone which supports dynamic updates, :iscman:`named` periodically 261re-signs RRsets which have not been re-signed as a result of some update action. 262The signature lifetimes are adjusted to spread the re-sign load over time rather 263than all at once. 264 265.. _dnssec_dynamic_zones_publishing_dnskey_records: 266 267Publishing DNSKEY Records 268========================= 269 270To insert the keys via dynamic update: 271 272:: 273 274 % nsupdate 275 > ttl 3600 276 > update add update.example DNSKEY 256 3 7 AwEAAZn17pUF0KpbPA2c7Gz76Vb18v0teKT3EyAGfBfL8eQ8al35zz3Y I1m/SAQBxIqMfLtIwqWPdgthsu36azGQAX8= 277 > update add update.example DNSKEY 257 3 7 AwEAAd/7odU/64o2LGsifbLtQmtO8dFDtTAZXSX2+X3e/UNlq9IHq3Y0 XtC0Iuawl/qkaKVxXe2lo8Ct+dM6UehyCqk= 278 > send 279 280In order to sign with these keys, the corresponding key files should also be 281placed in the :any:`key-directory`. 282 283.. _dnssec_dynamic_zones_nsec3: 284 285NSEC3 286===== 287 288To sign using :ref:`NSEC3 <advanced_discussions_nsec3>` instead of :ref:`NSEC 289<advanced_discussions_nsec>`, add an NSEC3PARAM record to the initial update 290request. The :term:`OPTOUT <Opt-out>` bit in the NSEC3 291chain can be set in the flags field of the 292NSEC3PARAM record. 293 294:: 295 296 % nsupdate 297 > ttl 3600 298 > update add update.example DNSKEY 256 3 7 AwEAAZn17pUF0KpbPA2c7Gz76Vb18v0teKT3EyAGfBfL8eQ8al35zz3Y I1m/SAQBxIqMfLtIwqWPdgthsu36azGQAX8= 299 > update add update.example DNSKEY 257 3 7 AwEAAd/7odU/64o2LGsifbLtQmtO8dFDtTAZXSX2+X3e/UNlq9IHq3Y0 XtC0Iuawl/qkaKVxXe2lo8Ct+dM6UehyCqk= 300 > update add update.example NSEC3PARAM 1 0 0 - 301 > send 302 303Note that the ``NSEC3PARAM`` record does not show up until :iscman:`named` has 304had a chance to build/remove the relevant chain. A private type record is 305created to record the state of the operation (see below for more details), and 306is removed once the operation completes. 307 308The ``NSEC3`` chain is generated and the ``NSEC3PARAM`` record is added before 309the ``NSEC`` chain is destroyed. 310 311While the initial signing and ``NSEC``/``NSEC3`` chain generation are occurring, 312other updates are possible as well. 313 314A new ``NSEC3PARAM`` record can be added via dynamic update. When the new 315``NSEC3`` chain has been generated, the ``NSEC3PARAM`` flag field is set to 316zero. At that point, the old ``NSEC3PARAM`` record can be removed. The old 317chain is removed after the update request completes. 318 319:iscman:`named` only supports creating new ``NSEC3`` chains where all the 320``NSEC3`` records in the zone have the same ``OPTOUT`` state. :iscman:`named` 321supports updates to zones where the ``NSEC3`` records in the chain have mixed 322``OPTOUT`` state. :iscman:`named` does not support changing the ``OPTOUT`` 323state of an individual ``NSEC3`` record; if the ``OPTOUT`` state of an 324individual ``NSEC3`` needs to be changed, the entire chain must be changed. 325 326To switch back to ``NSEC``, use :iscman:`nsupdate` to remove any ``NSEC3PARAM`` 327records. The ``NSEC`` chain is generated before the ``NSEC3`` chain is removed. 328 329.. _dnssec_dynamic_zones_dnskey_rollovers: 330 331DNSKEY Rollovers 332================ 333 334To perform key rollovers via a dynamic update, the ``K*`` files for the new keys 335must be added so that :iscman:`named` can find them. The new ``DNSKEY`` RRs can 336then be added via dynamic update. When the zones are being signed, they are 337signed with the new key set; when the signing is complete, the private type 338records are updated so that the last octet is non-zero. 339 340If this is for a KSK, the parent and any trust anchor repositories of the new 341KSK must be informed. 342 343The maximum TTL in the zone must expire before removing the old ``DNSKEY``. If 344it is a KSK that is being updated, the DS RRset in the parent must also be 345updated and its TTL allowed to expire. This ensures that all clients are able to 346verify at least one signature when the old ``DNSKEY`` is removed. 347 348The old ``DNSKEY`` can be removed via ``UPDATE``, taking care to specify the 349correct key. :iscman:`named` cleans out any signatures generated by the old 350key after the update completes. 351 352.. _dnssec_dynamic_zones_going_insecure: 353 354Going Insecure 355============== 356 357To convert a signed zone to unsigned using dynamic DNS, delete all the 358``DNSKEY`` records from the zone apex using :iscman:`nsupdate`. All signatures, 359``NSEC`` or ``NSEC3`` chains, and associated ``NSEC3PARAM`` records are removed 360automatically when the zone is supposed to be re-signed. 361 362This requires the :any:`dnssec-secure-to-insecure` option to be set to ``yes`` in 363:iscman:`named.conf`. 364 365In addition, if the ``auto-dnssec maintain`` or a :any:`dnssec-policy` is used, it 366should be removed or changed to ``allow`` instead; otherwise it will re-sign. 367 368.. _dnssec_tools: 369 370Manual Signing 371^^^^^^^^^^^^^^ 372 373There are several tools available to manually sign a zone. 374 375.. warning:: 376 377 Please note manual procedures are available mainly for backwards 378 compatibility and should be used only by expert users with specific needs. 379 380To set up a DNSSEC secure zone manually, a series of steps 381must be followed. Please see chapter 382:ref:`advanced_discussions_manual_key_management_and_signing` in the 383:doc:`dnssec-guide` for more information. 384 385Monitoring with Private Type Records 386^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 387 388The state of the signing process is signaled by private type records (with a 389default type value of 65534). When signing is complete, those records with a 390non-zero initial octet have a non-zero value for the final octet. 391 392If the first octet of a private type record is non-zero, the record indicates 393either that the zone needs to be signed with the key matching the record, or 394that all signatures that match the record should be removed. Here are the 395meanings of the different values of the first octet: 396 397 - algorithm (octet 1) 398 399 - key ID in network order (octet 2 and 3) 400 401 - removal flag (octet 4) 402 403 - complete flag (octet 5) 404 405Only records flagged as "complete" can be removed via dynamic update; attempts 406to remove other private type records are silently ignored. 407 408If the first octet is zero (this is a reserved algorithm number that should 409never appear in a ``DNSKEY`` record), the record indicates that changes to the 410``NSEC3`` chains are in progress. The rest of the record contains an 411``NSEC3PARAM`` record, while the flag field tells what operation to perform 412based on the flag bits: 413 414 0x01 OPTOUT 415 416 0x80 CREATE 417 418 0x40 REMOVE 419 420 0x20 NONSEC 421 422.. _secure_delegation: 423 424Secure Delegation 425~~~~~~~~~~~~~~~~~ 426 427Once a zone is signed on the authoritative servers, the last remaining step 428is to establish chain of trust [#validation]_ between the parent zone 429(``example.``) and the local zone (``dnssec.example.``). 430 431Generally the procedure is: 432 433 - **Wait** for stale data to expire from caches. The amount of time required 434 is equal to the maximum TTL value used in the zone before signing. This 435 step ensures that unsigned data expire from caches and resolvers do not get 436 confused by missing signatures. 437 - Insert/update DS records in the parent zone (``dnssec.example. DS`` record). 438 439There are multiple ways to update DS records in the parent zone. Refer to the 440documentation for the parent zone to find out which options are applicable to 441a given case zone. Generally the options are, from most- to least-recommended: 442 443 - Automatically update the DS record in the parent zone using 444 ``CDS``/``CDNSKEY`` records automatically generated by BIND. This requires 445 support for :rfc:`7344` in either parent zone, registry, or registrar. In 446 that case, configure BIND to :ref:`monitor DS records in the parent 447 zone <cds_cdnskey>` and everything will happen automatically at the right 448 time. 449 - Query the zone for automatically generated ``CDS`` or ``CDNSKEY`` records using 450 :iscman:`dig`, and then insert these records into the parent zone using 451 the method specified by the parent zone (web form, e-mail, API, ...). 452 - Generate DS records manually using the :iscman:`dnssec-dsfromkey` utility on 453 `zone keys`_, and then insert them into the parent zone. 454 455.. [#validation] For further details on how the chain of trust is used in practice, see 456 :ref:`dnssec_12_steps` in the :doc:`dnssec-guide`. 457 458 459 460DNSSEC Validation 461~~~~~~~~~~~~~~~~~ 462 463The BIND resolver validates answers from authoritative servers by default. This 464behavior is controlled by the configuration statement :namedconf:ref:`dnssec-validation`. 465 466By default a trust anchor for the DNS root zone is used. 467This trust anchor is provided as part of BIND and is kept up-to-date using 468:ref:`rfc5011.support`. 469 470.. note:: 471 DNSSEC validation works "out of the box" and does not require 472 additional configuration. Additional configuration options are intended only 473 for special cases. 474 475To validate answers, the resolver needs at least one trusted starting point, 476a "trust anchor." Essentially, trust anchors are copies of ``DNSKEY`` RRs for 477zones that are used to form the first link in the cryptographic chain of trust. 478Alternative trust anchors can be specified using :any:`trust-anchors`, but 479this setup is very unusual and is recommended only for expert use. 480For more information, see :ref:`trust_anchors_description` in the 481:doc:`dnssec-guide`. 482 483The BIND authoritative server does not verify signatures on load, so zone keys 484for authoritative zones do not need to be specified in the configuration 485file. 486 487Validation Failures 488^^^^^^^^^^^^^^^^^^^ 489 490When DNSSEC validation is configured, the resolver rejects any answers from 491signed, secure zones which fail to validate, and returns SERVFAIL to the 492client. 493 494Responses may fail to validate for any of several reasons, including 495missing, expired, or invalid signatures; a key which does not match the 496DS RRset in the parent zone; or an insecure response from a zone which, 497according to its parent, should have been secure. 498 499For more information see :ref:`dnssec_troubleshooting`. 500 501Coexistence With Unsigned (Insecure) Zones 502^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 503 504Zones not protected by DNSSEC are called "insecure," and these zones seamlessly 505coexist with signed zones. 506 507When the validator receives a response from an unsigned zone that has 508a signed parent, it must confirm with the parent that the zone was 509intentionally left unsigned. It does this by verifying, via signed 510and validated :ref:`NSEC/NSEC3 records 511<advanced_discussions_proof_of_nonexistence>`, that the parent zone contains no 512DS records for the child. 513 514If the validator *can* prove that the zone is insecure, then the 515response is accepted. However, if it cannot, the validator must assume an 516insecure response to be a forgery; it rejects the response and logs 517an error. 518 519The logged error reads "insecurity proof failed" and "got insecure 520response; parent indicates it should be secure." 521