| 1 | One page howto for signing your DNS zone with DNSSEC |
|---|
| 2 | ---------------------------------------------------- |
|---|
| 3 | |
|---|
| 4 | *** ON YOUR MASTER SERVER *** |
|---|
| 5 | |
|---|
| 6 | 1. First, verify that DNSSEC is enabled in /etc/namedb/named.conf |
|---|
| 7 | In the options { .. }; section, add the following, if it's not |
|---|
| 8 | already there: |
|---|
| 9 | |
|---|
| 10 | dnssec-enable yes; |
|---|
| 11 | |
|---|
| 12 | Then find the definition for your zone ("mytld"), and modify it as |
|---|
| 13 | shown below. |
|---|
| 14 | |
|---|
| 15 | * Note: if your zone file definition is already pointing to "mytld.signed" |
|---|
| 16 | from a previous exercise, revert this to "mytld", like in the example |
|---|
| 17 | below: |
|---|
| 18 | |
|---|
| 19 | zone "mytld" { |
|---|
| 20 | file "/etc/namedb/master/mytld"; |
|---|
| 21 | type master; |
|---|
| 22 | allow-transfer { key mydomain-key; }; |
|---|
| 23 | |
|---|
| 24 | key-directory "/etc/namedb/keys"; // <--- Add this |
|---|
| 25 | auto-dnssec maintain; // <--- Add this |
|---|
| 26 | update-policy local; // <--- Add this |
|---|
| 27 | // dnssec-secure-to-insecure yes; // <--- Add this |
|---|
| 28 | }; |
|---|
| 29 | |
|---|
| 30 | Save and exit |
|---|
| 31 | |
|---|
| 32 | 2. Restore the old zone file from the backup we made, if we have one, |
|---|
| 33 | as we're going to start over: |
|---|
| 34 | |
|---|
| 35 | # cd /etc/namedb/master |
|---|
| 36 | # cp mytld.backup mytld |
|---|
| 37 | |
|---|
| 38 | 3. Now reconfig the nameserver |
|---|
| 39 | |
|---|
| 40 | # rndc reconfig |
|---|
| 41 | |
|---|
| 42 | Make sure that your server still answers for your zone, using dig! |
|---|
| 43 | |
|---|
| 44 | Create a directory for the keys: |
|---|
| 45 | |
|---|
| 46 | # mkdir /etc/namedb/keys |
|---|
| 47 | # chown bind /etc/namedb/keys |
|---|
| 48 | |
|---|
| 49 | Give ownership of the /etc/namedb/master directory so BIND can sign |
|---|
| 50 | your zone and write the file: |
|---|
| 51 | |
|---|
| 52 | # chown -R bind /etc/namedb/master |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | 4. Preparing the keys |
|---|
| 57 | |
|---|
| 58 | If you've done the manual lab from before, you have already |
|---|
| 59 | generated keys, and we can reuse those. Otherwise, we'll generate |
|---|
| 60 | a new set of keys. |
|---|
| 61 | |
|---|
| 62 | a) You already have keys |
|---|
| 63 | |
|---|
| 64 | # cd /etc/namedb/master |
|---|
| 65 | # mv Kmytld* ../keys |
|---|
| 66 | |
|---|
| 67 | ... and skip to step 5 |
|---|
| 68 | |
|---|
| 69 | b) If you don't have keys yet: |
|---|
| 70 | |
|---|
| 71 | # cd /etc/namedb/keys |
|---|
| 72 | |
|---|
| 73 | - Generate first key pair (Zone Signing Key) |
|---|
| 74 | |
|---|
| 75 | # dnssec-keygen mytld |
|---|
| 76 | |
|---|
| 77 | ( will output something like: |
|---|
| 78 | Generating key pair......................+++++ + .... |
|---|
| 79 | Kmytld.+005+43116) |
|---|
| 80 | |
|---|
| 81 | - Generate second key pair (Key Signing Key) |
|---|
| 82 | |
|---|
| 83 | # dnssec-keygen -f KSK mytld |
|---|
| 84 | Kmytld.+005+52159 |
|---|
| 85 | |
|---|
| 86 | (once again, some output will show) |
|---|
| 87 | |
|---|
| 88 | Notice that we don't specify any flags such as algorithm, key size, |
|---|
| 89 | etc... We're using the defaults |
|---|
| 90 | |
|---|
| 91 | 5. Let's look at the keys: |
|---|
| 92 | |
|---|
| 93 | # cd /etc/namedb/keys |
|---|
| 94 | |
|---|
| 95 | # ls -l Kmytld* |
|---|
| 96 | -rw-r--r-- 1 root wheel 591 Feb 18 15:52 Kmytld.+005+32044.key |
|---|
| 97 | -rw------- 1 root wheel 1774 Feb 18 15:52 Kmytld.+005+32044.private |
|---|
| 98 | -rw-r--r-- 1 root wheel 417 Feb 18 15:52 Kmytld.+005+64860.key |
|---|
| 99 | -rw------- 1 root wheel 1010 Feb 18 15:52 Kmytld.+005+64860.private |
|---|
| 100 | |
|---|
| 101 | Make the keys readable by BIND: |
|---|
| 102 | |
|---|
| 103 | # chgrp bind K* |
|---|
| 104 | # chmod g+r K* |
|---|
| 105 | |
|---|
| 106 | 6. We're ready to sign! |
|---|
| 107 | |
|---|
| 108 | First take a backup of the zone before it was signed |
|---|
| 109 | |
|---|
| 110 | # cd /etc/namedb/master |
|---|
| 111 | # cp mytld mytld.unsigned |
|---|
| 112 | |
|---|
| 113 | If there is an old "mytld.signed" file, you can get rid of it just in |
|---|
| 114 | case, but it won't be used anyway (this is just to avoid confusion): |
|---|
| 115 | |
|---|
| 116 | # rm mytld.signed |
|---|
| 117 | |
|---|
| 118 | Signal BIND to sign the zone (the backup made above will be untouched) |
|---|
| 119 | |
|---|
| 120 | # rndc sign mytld |
|---|
| 121 | |
|---|
| 122 | Take a look at the /etc/namedb/log/general log: |
|---|
| 123 | |
|---|
| 124 | # tail -10 /etc/namedb/log/general |
|---|
| 125 | |
|---|
| 126 | 18-Feb-2011 15:57:41.168 set up managed keys zone for view _default, file 'managed-keys.bind' |
|---|
| 127 | 18-Feb-2011 15:57:41.184 reloading configuration succeeded |
|---|
| 128 | 18-Feb-2011 15:57:41.193 any newly configured zones are now loaded |
|---|
| 129 | 18-Feb-2011 15:57:43.666 received control channel command 'sign mytlf' |
|---|
| 130 | 18-Feb-2011 15:57:43.668 zone mytlf/IN: reconfiguring zone keys |
|---|
| 131 | 18-Feb-2011 15:57:43.693 zone mytlf/IN: next key event: 19-Feb-2011 03:57:43.693 |
|---|
| 132 | |
|---|
| 133 | 7. Take a look at the signed zone: |
|---|
| 134 | |
|---|
| 135 | # cd /etc/namedb/master |
|---|
| 136 | # ls -l mytld* |
|---|
| 137 | |
|---|
| 138 | Notice the ".jnl" file: |
|---|
| 139 | |
|---|
| 140 | -rw-r--r-- 1 bind wheel 535 Feb 18 14:22 mytld |
|---|
| 141 | -rw-r--r-- 1 bind wheel 3473 Feb 18 15:57 mytld.jnl |
|---|
| 142 | |
|---|
| 143 | The zone is now DYNAMICALLY managed by bind. |
|---|
| 144 | |
|---|
| 145 | If you want to make changes, you either need to: |
|---|
| 146 | |
|---|
| 147 | a) freeze the zone, edit, thaw: |
|---|
| 148 | |
|---|
| 149 | # rndc freeze mytld |
|---|
| 150 | # vi ... // remember the serial! |
|---|
| 151 | # rndc thaw mytld |
|---|
| 152 | |
|---|
| 153 | b) use nsupdate |
|---|
| 154 | |
|---|
| 155 | # nsupdate -l |
|---|
| 156 | > update add mail.mytld. 300 A 1.2.3.4 |
|---|
| 157 | > send |
|---|
| 158 | > quit |
|---|
| 159 | |
|---|
| 160 | # tail -10 /etc/namedb/log/general |
|---|
| 161 | |
|---|
| 162 | 18-Feb-2011 16:07:00.374 client 127.0.0.1#57195: updating zone 'mytld/IN': adding an RR at 'mail.phil' A |
|---|
| 163 | |
|---|
| 164 | If you use the nsupdate method, check the SOA after every update -- |
|---|
| 165 | what do you notice ? |
|---|
| 166 | |
|---|
| 167 | 8. Now we need to include the DS in the parent zone ! |
|---|
| 168 | |
|---|
| 169 | (DS = digest fingerprint of the Key Signing Key). |
|---|
| 170 | |
|---|
| 171 | Generate a "DS" from your key: |
|---|
| 172 | |
|---|
| 173 | Find which key is the key signing key: |
|---|
| 174 | |
|---|
| 175 | # cd /etc/namedb/keys |
|---|
| 176 | # more Kmytld*key |
|---|
| 177 | |
|---|
| 178 | Look at which one has "IN DNSKEY 257". |
|---|
| 179 | |
|---|
| 180 | # dnssec-dsfromkey Kmytld.+005+32044 >dsset-mytld. |
|---|
| 181 | |
|---|
| 182 | REMEMBER the dot! |
|---|
| 183 | |
|---|
| 184 | 9. Upload the dsset for your zone (containing the hash of your zone) to the |
|---|
| 185 | ROOT server: |
|---|
| 186 | |
|---|
| 187 | # scp dsset-mytld. adm@rootserv.ws.nsrc.org: |
|---|
| 188 | |
|---|
| 189 | The password is the same as in class |
|---|
| 190 | |
|---|
| 191 | 10. Tell the instructor you have done so! |
|---|
| 192 | |
|---|
| 193 | The instructor will include the DS-set in the root and re-sign the zone |
|---|
| 194 | |
|---|
| 195 | *** ON THE RESOLVER *** |
|---|
| 196 | |
|---|
| 197 | You need to log in to your cache machine, i.e. for group 1, you would use |
|---|
| 198 | cache.grp1.ws.nsrc.org, as you did in the unbound config exercise |
|---|
| 199 | |
|---|
| 200 | 11. Grab the root key |
|---|
| 201 | |
|---|
| 202 | NOTE: This is only for the purpose of this lab - on the Internet, |
|---|
| 203 | you would simply use "unbound-anchor" to download the real root.key, |
|---|
| 204 | and set "auto-trust-anchor-file:" unbound.conf, and let unbound update |
|---|
| 205 | the key when necessary. |
|---|
| 206 | |
|---|
| 207 | In this lab: |
|---|
| 208 | |
|---|
| 209 | # scp adm@rootserv.ws.nsrc.org:root.key /usr/local/etc/unbound/root.key |
|---|
| 210 | |
|---|
| 211 | Edit the /usr/local/etc/unbound/unbound.conf file: |
|---|
| 212 | |
|---|
| 213 | Find the "trust-anchor-file:" line, and change it from: |
|---|
| 214 | |
|---|
| 215 | # trust-anchor-file: "" |
|---|
| 216 | |
|---|
| 217 | to |
|---|
| 218 | |
|---|
| 219 | trust-anchor-file: "/usr/local/etc/unbound/root.key" |
|---|
| 220 | |
|---|
| 221 | 12. Reload the nameserver |
|---|
| 222 | |
|---|
| 223 | # /usr/local/etc/rc.d/unbound restart |
|---|
| 224 | |
|---|
| 225 | 13. dig @localhost +dnssec mytld. SOA |
|---|
| 226 | |
|---|
| 227 | What do you notice ? |
|---|