View | Details | Raw Unified | Return to bug 157245 | Differences between
and this patch

Collapse All | Expand All

(-)chapter.sgml (-1 / +320 lines)
Lines 3872-3877 Link Here
3872
    </sect2>
3872
    </sect2>
3873
3873
3874
    <sect2>
3874
    <sect2>
3875
      <title>DNSSEC</title>
3876
      <indexterm>
3877
        <primary>BIND</primary>
3878
        <secondary>DNS security extensions</secondary>
3879
      </indexterm>
3880
3881
      <para>Domain Name System Security Extensions, or <acronym>DNSSEC</acronym>
3882
	for short, is a suite of specifications to protect the 
3883
	<acronym>DNS</acronym> clients, i.e. Internet resolvers, from forged
3884
	<acronym>DNS</acronym> data, such as spoofed <acronym>DNS</acronym>
3885
	records.  By using digital signatures, a resolver can verify the
3886
	integrity and authenticity of the record.  It is worth noticing that
3887
	<acronym>DNSSEC</acronym> does only provide integrity, it does not
3888
	provide either confidentiality nor protection against false assumptions,
3889
	meaning that it cannot protect against people going to 
3890
	<hostid role="domainname">example.com</hostid> instead of 
3891
	<hostid role="domainname">example.net</hostid> and similar.  The only 
3892
	thing <acronym>DNSSEC</acronym> does is authenticate that the data is 
3893
	from the domain owner and that it has not been compromised in transit. 
3894
	The security of <acronym>DNS</acronym> is believed to be an important 
3895
	step in securing the Internet in general.  For a more in-depth 
3896
	knowledge of how <acronym>DNSSEC</acronym> works, the relevant
3897
	<acronym>RFC</acronym>s is a good place to start.  See the list at the
3898
	end of this chapter.</para>
3899
3900
      <para>The next two sections will demonstrate how to enable
3901
	<acronym>DNSSEC</acronym> for an authorative <acronym>DNS</acronym>
3902
	server and a recursive (or cashing) <acronym>DNS</acronym> server
3903
	running <acronym>BIND</acronym>9.  While all versions of
3904
	<acronym>BIND</acronym>9 supports <acronym>DNSSEC</acronym>, it is
3905
	necessary to have at least version 9.6.2 in order to be able to use the
3906
	signed root zone when validating <acronym>DNS</acronym> queries.  This is
3907
	because earlier versions lack the required algorithms to enable
3908
	validation using the root zone key.  It is strongly recommended to use
3909
	<acronym>BIND</acronym> 9.7 or later, to take advantage of the automatic
3910
	key updating function for the root key, as well as other functions to
3911
	automatically keep zones signed and signatures up to date.  Where
3912
	configurations differ between 9.6.2 and 9.7 and later, differences will
3913
	be pointed out.</para>
3914
3915
      <sect3>
3916
	<title>Recursive <acronym>DNS</acronym> server configuration</title>
3917
3918
	<para>To enable <acronym>DNSSEC</acronym> validation of queries done by
3919
	  a recursive <acronym>DNS</acronym> server, a few changes to
3920
	  <filename>named.conf</filename> are needed.  However, before changing
3921
	  <filename>named.conf</filename> the root zone key, or trust anchor,
3922
	  must be aquired.  Currently the root zone key is not available in a
3923
	  file format <acronym>BIND</acronym> understands, so this has to be
3924
	  manually generated.  The key itself can be obtained by querying the
3925
	  root zone for it, using <appication>dig</application>.  By running 
3926
	  <screen>&prompt.user; <userinput>dig +multi +noall +answer DNSKEY .
3927
	  &gt; root.dnskey</userinput></screen> the key will end up in
3928
	  <filename>root.dnskey</filename>. The contents should look something
3929
	  like this:<programlisting>
3930
. 93910 IN DNSKEY 257 3 8 (
3931
            AwEAAagAIKlVZrpC6Ia7gEzahOR+9W29euxhJhVVLOyQ
3932
            bSEW0O8gcCjFFVQUTf6v58fLjwBd0YI0EzrAcQqBGCzh
3933
            /RStIoO8g0NfnfL2MTJRkxoXbfDaUeVPQuYEhg37NZWA
3934
            JQ9VnMVDxP/VHL496M/QZxkjf5/Efucp2gaDX6RS6CXp
3935
            oY68LsvPVjR0ZSwzz1apAzvN9dlzEheX7ICJBBtuA6G3
3936
            LQpzW5hOA2hzCTMjJPJ8LbqF6dsV6DoBQzgul0sGIcGO
3937
            Yl7OyQdXfZ57relSQageu+ipAdTTJ25AsRTAoub8ONGc
3938
            LmqrAmRLKBP1dfwhYB4N7knNnulqQxA+Uk1ihz0=
3939
            ) ; key id = 19036
3940
. 93910 IN DNSKEY 256 3 8 (
3941
            AwEAAcaGQEA+OJmOzfzVfoYN249JId7gx+OZMbxy69Hf
3942
            UyuGBbRN0+HuTOpBxxBCkNOL+EJB9qJxt+0FEY6ZUVjE
3943
            g58sRr4ZQ6Iu6b1xTBKgc193zUARk4mmQ/PPGxn7Cn5V
3944
            EGJ/1h6dNaiXuRHwR+7oWh7DnzkIJChcTqlFrXDW3tjt
3945
            ) ; key id = 34525
3946
          </programlisting>Do not be alarmed if the keys differ, they might
3947
          have changed since this was last updated.  This output actually
3948
          contains two keys.  The first key in the listing, with the value 257
3949
          behind the DNSKEY record type, is the one needed. The value
3950
          indicates that this is a Secure Entry Point, more commonly known as
3951
          a Key Signing Key (<acronym role="Key Signing Key">KSK</acronym>).
3952
          The second key, with value 256, is a subordinate key, commonly 
3953
          called a Zone Signing Key
3954
          (<acronym role="Zone Signing Key">ZSK</acronym>).  More on the
3955
          different key types later in the section <xref
3956
          linkend="dns-dnssec-auth">.</para>
3957
3958
        <para>Now that the key is obtained, it has to be verified to be
3959
          correct, and then made into a format <acronym>BIND</acronym> can
3960
          use.  The next step is to generate a
3961
          <acronym role="Delegation signer">DS</acronym> 
3962
          <acronym role="Resource Record">RR</acronym> set.  This is done by
3963
          running <screen>&propmt.user; <userinput>dnssec-dsfromkey -f
3964
          root-dnskey . &gt; root.ds</userinput></screen>, which will emit two
3965
          <acronym>RR</acronyms>s into <filename>root.ds</filename>.  These
3966
          records are using SHA-1 and SHA-256 respectively, and should look
3967
          similar to this, where the longer is using SHA-256.<programlisting>
3968
. IN DS 19036 8 1 B256BD09DC8DD59F0E0F0D8541B8328DD986DF6E
3969
. IN DS 19036 8 2 49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5
3970
	  </programlisting>The SHA-256 <acronym>RR</acronym> can now be
3971
	  compared to the digest in <ulink
3972
	  url="https://data.iana.org/root-anchors/root-anchors.xml">
3973
	  https://data.iana.org/root-anchors/root-anchors.xml</ulink>.  To be
3974
	  absolutely sure that the key has not been tampered with, the data in
3975
	  the <acronym>XML</acronym> file can be verified using the
3976
	  <acronym>PGP</acronym> signature in <ulink
3977
	  url="https://data.iana.org/root-anchors/root-anchors.asc">
3978
	  https://data.iana.org/root-anchors/root-anchors.asc</ulink>.</para>
3979
	    
3980
	<para>The last step is to format the key to a format
3981
	  <acronym>BIND</acronym> understand. This differs a little between
3982
	  version 9.6.2 and 9.7 and later.  Both uses a
3983
	  <literal>managed-keys</literal> clause, but support for
3984
	  <literal>initial-key</literal> was added in 9.7.
3985
	  <literal>initial-key</literal> tells <acronym>BIND</acronym>
3986
	  automatic tracking of the key. With <acronym>BIND</acronym> 9.6.2
3987
	  it is necessary to update the key manually when it is changed. The
3988
	  format should look like, for <acronym>BIND</acronym> 9.6.2:
3989
	  <programlisting>
3990
managed-keys {
3991
	"." 257 3 8
3992
	"AwEAAagAIKlVZrpC6Ia7gEzahOR+9W29euxhJhVVLOyQbSEW0O8gcCjF
3993
	FVQUTf6v58fLjwBd0YI0EzrAcQqBGCzh/RStIoO8g0NfnfL2MTJRkxoX
3994
	bfDaUeVPQuYEhg37NZWAJQ9VnMVDxP/VHL496M/QZxkjf5/Efucp2gaD
3995
	X6RS6CXpoY68LsvPVjR0ZSwzz1apAzvN9dlzEheX7ICJBBtuA6G3LQpz
3996
	W5hOA2hzCTMjJPJ8LbqF6dsV6DoBQzgul0sGIcGOYl7OyQdXfZ57relS
3997
	Qageu+ipAdTTJ25AsRTAoub8ONGcLmqrAmRLKBP1dfwhYB4N7knNnulq
3998
	QxA+Uk1ihz0=";
3999
};
4000
	  </programlisting>For 9.7 the format will instead be:
4001
	  <programlisting>
4002
managed-keys {
4003
        "." initial-key 257 3 8
4004
	"AwEAAagAIKlVZrpC6Ia7gEzahOR+9W29euxhJhVVLOyQbSEW0O8gcCjF
4005
	FVQUTf6v58fLjwBd0YI0EzrAcQqBGCzh/RStIoO8g0NfnfL2MTJRkxoX
4006
	bfDaUeVPQuYEhg37NZWAJQ9VnMVDxP/VHL496M/QZxkjf5/Efucp2gaD
4007
	X6RS6CXpoY68LsvPVjR0ZSwzz1apAzvN9dlzEheX7ICJBBtuA6G3LQpz
4008
	W5hOA2hzCTMjJPJ8LbqF6dsV6DoBQzgul0sGIcGOYl7OyQdXfZ57relS
4009
	Qageu+ipAdTTJ25AsRTAoub8ONGcLmqrAmRLKBP1dfwhYB4N7knNnulq
4010
	QxA+Uk1ihz0=";
4011
};
4012
	  </programlisting>The <literal>managed-keys</literal> directive can
4013
	  now be added to <filename>named.conf</filename> either directly or
4014
	  by including a file containing the key.  After all this is done it
4015
	  is just to tell <acronym>BIND</acronym> to do
4016
	  <acronym>DNSSEC</acronym> validation on queries.  This is achieved by
4017
	  editing <filename>named.conf</filename> and add the following to the
4018
	  <literal>options</literal> directive:<programlisting>
4019
dnssec-enable yes;
4020
dnssec-validation yes;
4021
            </programlisting></para>
4022
4023
	<para>To verify that it is actually working, use
4024
	  <application>dig</application> to make a query for a signed zone
4025
	  using the resolver just set up.  A successful reply will contain
4026
	  the <literal><acronym role="Authenticated Data">AD</acronym>
4027
	  </literal> flag to indicate the data was authenticated.  Running a
4028
	  query such as <screen>&prompt.user; <userinput>dig @resolver +dnssec
4029
	  se ds</userinput><screen> should return the <acronym>DS</acronym>
4030
	  <acronym>RR</acronyms> for the .se zone.  In the
4031
	  <literal>flags:</literal> section the
4032
	  <literal><acronym>AD</acronym></literal> flag should be set, as seen
4033
	  in:<programlisting>
4034
...
4035
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1
4036
...
4037
	  </programlisting>.  This means that the resolver is now capable of
4038
	  authenticate made <acronym>DNS</acronym>queries.</para>
4039
      </sect3>
4040
4041
      <sect3 id="dns-dnssec-auth">
4042
        <title>Authorative <acronym>DNS</acronym> server configuration</title>
4043
        <para>In order to get an authorative nameserver to serve a
4044
          <acronym>DNSSEC</acronym> signed zone, a little more work is
4045
          required.  To sign a zone, two cryptographic keys for that zone must
4046
          be generated. These two keys are usually called the Key Signing Key
4047
          (<acronym role="Key Signing Key">KSK</acronym>) and Zone Signing Key
4048
          (<acronym role="Zone Signing Key">ZSK</acronym>) respectively.  The
4049
          <acronym role="Key Signing Key">KSK</acronym> is used to build a chain
4050
          of authority to the data in need of validation and as such also called
4051
          a Secure Entry Point (<acronym role="Secure Entry
4052
          Point">SEP</acronym>) key.  This key needs to be published in the
4053
          parent zone as well, to establish the trust chain.  How this is
4054
          accomplished depends on the parent zone owner. The <acronym role="Zone
4055
          Signing Key">ZSK</acronym> is used to sign the zone, and only needs to
4056
          be published there.</para>
4057
4058
        <para>To enable <acronym>DNSSEC</acronym> for the <hostid
4059
          role="domainname">example.com</hostid> zone depicted in previous
4060
          examples, the first step is to use
4061
          <application>dnssec-keygen</application> to generate the
4062
          <acronym>KSK</acronym> and <acronym>ZSK</acronym> keypair.  This keypair
4063
          can utilize different cryptograhic algorithms.  Currently the mandatory
4064
          algorithm is <literal>RSA/SHA-1</literal>.  In the examples the key
4065
          length used is 2048 bits for the <acronym>KSK</acronym> and 1024 bits
4066
          for the <acronym>ZSK</acronym>.  To generate the
4067
          <acronym>KSK</acronym> for <hostid
4068
          role="domainname">example.com</hostid>, run <screen>&promt.user;
4069
          <userinput>dnssec-keygen -f KSK -a RSASHA1 -b 2048 -n ZONE
4070
          example.com</userinput></screen> and to generate the
4071
          <acronym>ZSK</acronym>, run <screen>&promt.user;
4072
          <userinput>dnssec-keygen -a RSASHA1 -b 1024 -n ZONE
4073
          example.com</userinput></screen>.
4074
          <application>dnssec-keygen</application> outputs two files, the public
4075
          and the private keys in files named similar to
4076
          <filename>Kexample.com.+005+nnnnn.key</filename> (public) and
4077
          <filename>Kexample.com.+005+nnnnn.private</filename> (private). The
4078
          <literal>nnnnn</literal> part of the file name is a five digit key ID.
4079
          Keep track of which key ID belongs to which key.  This is especially
4080
          important when having more than one key in a zone.  The public key
4081
          files can now be included in the zone file, using the
4082
          <literal>$include</literal> statement. It should look something like
4083
          this:<programlisting>
4084
$include Kexample.net.+005+nnnnn.key    ; ZSK
4085
$include Kexample.net.+005+nnnnn.key    ; KSK
4086
	  </programlisting></para>
4087
4088
	<para>The only steps left is to sign the zone and tell
4089
	  <acronym>BIND</acronym> to use the signed zonefile.  To sign a zone
4090
	  <application>dnssec-signzone</application> is used.  The command to
4091
	  sign the zone <hostid role="domainname">example.com</hostid>, located in
4092
	  <filename>example.com.db</filename> would look similar to
4093
	  <screen>&promt.user; <userinput>dnssec-signzone -o example.com -k
4094
	  Kexample.com+005+nnnnn example.com.db
4095
	  Kexample.com+005+nnnnn.key</userinput></screen>. The key supplied to
4096
	  the <literal>-k</literal> argument is the <acronym>KSK</acronym> and
4097
	  the other key file is the <acronym>ZSK</acronym> that should be used
4098
	  in the signing.  It is possible to supply more than one
4099
	  <acronym>KSK</acronym> and <acronym>ZSK</acronym>, which will result
4100
	  in the zone being signed with all supplied keys.  This can be needed
4101
	  to supply zone data signed using more than one algorithm.  The output
4102
	  of <application>dnssec-signzone</application> is a zone file with all
4103
	  <acronym>RR</acronym>s signed.  This output will end up in a file with
4104
	  the extension <literal>.signed</literal>, such as
4105
	  <filename>example.com.db.signed</filename>.  To use this signed zone
4106
	  just modify the zone directive in <filename>named.conf</filename> to
4107
	  use this file.  By default, the signatures are only valid 30 days,
4108
	  meaning that the zone needs to be resigned within this time.  It is
4109
	  possible to make a script and a cron job to do this.  See relevant
4110
	  manuals for details.</para>
4111
	<para>Some cautionary words at the end.  Be sure to keep private keys
4112
	  confidential, as with all cryptographic keys.  When changing a key it
4113
	  is best to include the new key into the zone, while still signing with
4114
	  the old key, and then move over to using the new key to sign.  After
4115
	  these steps are done the old key can be removed from the zone.
4116
	  Failiure to do this might render the <acronym>DNS</acronym> data
4117
	  unavailable for a time, untill the new key has propagated through the
4118
	  <acronym>DNS</acronym> hierarchy.  For more information on key
4119
	  rollovers and other <acronym>DNSSEC</acronym> operational issues, see
4120
	  <ulink
4121
	  url="http://www.ietf.org/rfc/rfc4641.txt"><acronym>RFC</acronym> 4641:
4122
	  <acronym>DNSSEC</acronym> Operational practices</ulink>.</para>
4123
      </sect3>
4124
4125
      <sect3>
4126
        <title>Automation using <acronym>BIND</acronym>9.7 or later</title>
4127
        <para>Beginning with <acronym>BIND</acronym> version 9.7, a new feature
4128
          called <emphasis>Smart Signing</emphasis> was introduced.  This
4129
          feature aims to make the key management and signing process simpler by
4130
          automating parts of the task.  By putting the keys into a directory,
4131
          from now on called a key repository, and using the new option
4132
          <literal>auto-dnssec</literal> it is possible to create a dynamic zone
4133
          which will be resigned as needed.  To update this zone the tool
4134
          <application>nsupdate</application> with the new option
4135
          <literal>-l</literal> is used. <application>rndc</application> has
4136
          also grown the ability to sign zones with keys in the key repository,
4137
          using the option <literal>sign</literal>.  To make this work, put
4138
          something similar to what is shown below into
4139
          <filename>named.conf</filename>.<programlisting>
4140
zone example.com {
4141
	type master;
4142
	key-directory "keys";
4143
	update-policy local;
4144
	auto-dnssec maintain;
4145
	file "dynamic/example.com.zone";
4146
};
4147
	  </programlisting>This will tell named to use automatic signing and
4148
	  updating of the zone <hostid role="domainname">example.com</hostid>.
4149
	  After this is done just generate keys for the zone as explained in
4150
	  <xref linkened="dns-dnssec-auth">, put these in the key repository
4151
	  denoted by <literal>key-directory</literal> in the zone configuration
4152
	  and sign the zone using <application>rndc</application>.  Updates to
4153
	  the zone is done using <application>nsupdate</application> which will
4154
	  take care of resigning the zone with the new data added.  For further
4155
	  details, see <xref linkened="dns-read"> and the
4156
	  <acronym>BIND</acronym> documentation.</para>
4157
	</sect3>
4158
4159
    </sect2>
4160
4161
    <sect2>
3875
      <title>Security</title>
4162
      <title>Security</title>
3876
4163
3877
      <para>Although BIND is the most common implementation of DNS,
4164
      <para>Although BIND is the most common implementation of DNS,
Lines 3897-3903 Link Here
3897
      </tip>
4184
      </tip>
3898
    </sect2>
4185
    </sect2>
3899
4186
3900
    <sect2>
4187
    <sect2 id="dns-read">
3901
      <title>Further Reading</title>
4188
      <title>Further Reading</title>
3902
4189
3903
      <para>BIND/<application>named</application> manual pages:
4190
      <para>BIND/<application>named</application> manual pages:
Lines 3932-3937 Link Here
3932
	      url="http://tools.ietf.org/html/rfc1035">RFC1035
4219
	      url="http://tools.ietf.org/html/rfc1035">RFC1035
3933
	      - Domain Names - Implementation and Specification</ulink></para>
4220
	      - Domain Names - Implementation and Specification</ulink></para>
3934
	</listitem>
4221
	</listitem>
4222
4223
	<listitem>
4224
	  <para><ulink
4225
	      url="http://tools.ietf.org/html/rfc4033">RFC4033
4226
	      - DNS Security Introduction and Requirements</ulink></para>
4227
	</listitem>
4228
4229
	<listitem>
4230
	  <para><ulink
4231
	      url="http://tools.ietf.org/html/rfc4034">RFC4034
4232
	      - Recource Records for the DNS Security Extensions</ulink></para>
4233
	</listitem>
4234
4235
	<listitem>
4236
	  <para><ulink
4237
	      url="http://tools.ietf.org/html/rfc4035">RFC4035
4238
	      - Protocol Modifications for the DNS Security Extensions</ulink></para>
4239
	</listitem>
4240
4241
	<listitem>
4242
	  <para><ulink
4243
	      url="http://tools.ietf.org/html/rfc4641">RFC4641
4244
	      - DNSSEC Operational Practices</ulink></para>
4245
	</listitem>
4246
4247
	<listitem>
4248
	  <para><ulink
4249
	      url="http://tools.ietf.org/html/rfc5011">RFC 5011
4250
	      - Automated Updates of DNS Security (<acronym>DNSSEC</acronym>
4251
	      Trust Anchors</ulink></para>
4252
	</listitem>
4253
3935
      </itemizedlist>
4254
      </itemizedlist>
3936
    </sect2>
4255
    </sect2>
3937
  </sect1>
4256
  </sect1>

Return to bug 157245