Agenda: dnssec-bind-manual-zsk-rollover.txt

File dnssec-bind-manual-zsk-rollover.txt, 5.9 KB (added by admin, 5 years ago)
Line 
1Manual Key Rollover Exercise
2----------------------------
3
4OBJECTIVE
5
6We are going to roll the ZSK for the zones we have just signed.
7
8PLEASE make note of the KSK/ZSK IDs and write them down on a piece of paper
9as you work to remember which is which.
10
11REMINDERS
12
13 - we are keeping our keys in /etc/namedb/keys/
14
15 - we currently have two pairs of keys in that directory, one ZSK and one KSK.
16   Each pair is represented by two files, one ending in ".key" (the
17   public key) and one ending in ".private" (the private key)
18
19 - there is a DS RRSet in the "root" zone corresponding to our KSK
20
21
22ZSK ROLLOVER
23
241. Take a look at what keys we have already generated. Make a note
25of the names of the files containing the current ZSK and KSK.
26
27  $ cd /etc/namedb/keys/
28  $ ls K*
29
302. Generate a new ZSK, which we will use to replace the old one.
31
32  $ sudo dnssec-keygen -a RSASHA256 -b 1024 -n ZONE mytld
33
34  (replacing mytld with the name of your zone)
35
36  Which might output:
37
38  Kmytld.+008+45000
39
40Make sure all the keyfiles are readable by the named process:
41
42  $ sudo chown bind K*
43  $ sudo chmod u+r K*
44  $ ls
45
46You should now have a third key pair in the directory. If you check the
47DNSKEY RDATA, you should see the flags field is 256 (i.e. this is a ZSK,
48not a KSK). Make a note of the name of the file containing the new ZSK.
49
503. Take a look at your current DNSKEY RRSet.
51
52  $ dig mytld dnskey +multi
53
54Your zone should contain one KSK and one ZSK (check the flags - 257/256 -
55to distinguish between them).
56
57We need to add the new key to the zone, so it gets included in the next
58signing. At the end of the file /etc/namedb/master/mytld, ADD the new key:
59
60    $include "/etc/namedb/keys/Kmytld.+008+45000.key";
61
62    Increment the serial number.
63
64    Save the file and exit
65
664. Re-sign your zone to get the new ZSK signed, but we will NOT sign using
67   the new ZSK - we only want the new ZSK to be signed by the current ZSK.
68   This is called a "pre publish".
69
70  $ cd /etc/namedb/keys
71  $ sudo dnssec-signzone -o mytld -k Kmytld.+008+52159 ../master/mytld Kmytld.+008+51333
72
73  (the key tag/id numbers are from the previous manual signing lab)
74
75  Notice in the above example that we are only using the current ZSK
76  to sign, *NOT* the new one - this is to make sure that dnssec-signzone
77  doesn't try to sign with both ZSKs. It wouldn't be "bad", but it would
78  mean twice the data in the zone!
79
80  So we tell dnssec-signzone exactly which keys to use when doing a
81  rollover, PRECISELY because you want to control the timing of when
82  a key is introduced, used to sign, and finally retired.
83
84  The output of the above command should be:
85
86Zone signing complete:
87Algorithm: RSASHA256: KSKs: 1 active, 0 stand-by, 0 revoked
88                      ZSKs: 1 active, 1 stand-by, 0 revoked
89mytld.signed
90
91  Notice the ZSKs: 1 active, 1 stand-by
92
935. See what difference this has made to the zone.
94
95  $ sudo rndc reload mytld
96  $ dig @10.10.X.1 mytld dnskey
97  $ dig @10.10.X.1 mytld dnskey +dnssec
98  $ dig @10.10.X.1 mytld soa +dnssec
99
100Your zone should now contain one KSK and two ZSKs; both ZSKs should be
101present in the DNSKEY RRSet, which should be signed by the KSK.
102
103BUT the SOA record (and other RRSets in the zone) should ONLY be signed once,
104using the old ZSK. And the DNSKEY RRset should show all 3 keys (1 KSK, 2 ZSKs).
105This is called "pre-publish".
106
107At this time, we should in principle wait 2 x TTL for both ZSKs to
108show up in everyone's cache (by default it is 120 seconds, or 2 minutes,
109in our lab, but this will be different "in real life"). Anyways, let's
110wait for at least 2 minutes before we sign with the new ZSK instead of the
111old ZSK.
112
113After 2 minutes, ask one of your neighbors if they can lookup the DNSKEY
114for your domain. They can check the in-class cache (10.10.0.230) and,
115if they have configured it, their own cache.
116
117Again, the command to lookup the keys is:
118
119  $ dig mytld dnskey
120
121Once we are certain that "all the internet" (everyone in the class)
122can see both keys, we can sign with the new ZSK.
123
1246. Sign with the new ZSK.
125
126   Remember, we have 3 keys - in our zone, we have:
127
128        $include "/etc/namedb/keys/Kmytld.+008+52159.key"; // KSK
129        $include "/etc/namedb/keys/Kmytld.+008+51333.key"; // ZSK we retire
130        $include "/etc/namedb/keys/Kmytld.+008+45000.key"; // new ZSK
131
132   Increment the serial number. Then:
133
134   $ cd /etc/namedb/keys
135   $ sudo dnssec-signzone -o mytld -k Kmytld.+008+52159 ../master/mytld Kmytld.+008+45000
136
137... Notice how we now use 45000 (second ZSK) to sign, not 51333 anymore
138
139Now, reload the zone to propagage the changes
140
141   $ sudo rndc reload mytld
142
143Check with dig like in step 5 that you are seeing only ONE signature for your
144RRsets - which means we are only signing using ONE ZSK - you still have to
145wait for the TTL to expire before you can retire the old ZSK.
146
147
1487. Now you should notice, using dig like in step 5, that we are only
149   signing with one key
150
151   $ dig www.mytld +dnssec
152
153But also verify that the OLD ZSK is still published in the DNSKEY RRset:
154
155   $ dig mytld dnskey
156
157You should still see three keys.
158
1598. Retire the old ZSK.
160
161After waiting at least 2 minutes (120s), retire the old ZSK:
162
163  $ cd /etc/namedb/master/
164
165  Edit the zone file and add a comment sign (';') in front of the old ZSK
166  (double check which key!)
167
168  $ sudo ee mytld
169
170$include "/etc/namedb/keys/Kmytld.+008+52159.key";  // KSK
171;$include "/etc/namedb/keys/Kmytld.+008+51333.key"; // ZSK (commented out)
172$include "/etc/namedb/keys/Kmytld.+008+45000.key";  // new ZSK
173
174  Increment the serial number.
175
176  Now resign the zone, but you will notice that we explicitly DON'T specify
177  the ZSK we just commented:
178
179  $ cd /etc/namedb/keys
180  $ sudo dnssec-signzone -o mytld -k Kmytld.+008+52159 ../master/mytld Kmytld.+008+45000
181  $ sudo rndc reload mytld
182  $ tail /etc/namedb/log/general
183
1849. Like in the step 5, check that signatures still work, and that
185   the OLD KZK is no longer in the RRset
186
187   Also, check the RRSIGs (dig +dnssec soa mytld) in your zone show the
188   key ID of the new ZSK.
189
190   Does your domain still work ? :)
191