Agenda: dns-delegation-exercise2.txt

File dns-delegation-exercise2.txt, 13.3 KB (added by trac, 5 years ago)
Line 
1DNS Exercise - Part II
2======================
3
4In this exercise, you will *delegate* a subdomain of your own domain.
5
6In order to keep things simple, it will work like this: each machine will
7delegate a subdomain to the next host along (which will be the master) and the
8next one after that (which will be the slave).
9
10Example:
11
12* Let's say you are host103.dns and have domain `utopia.dns` already set up
13
14* You will pick a subdomain, let's say `elmo.utopia.dns`
15
16* You will delegate this subdomain to host104.dns and host105.dns
17  (host105.dns is the master and host106.dns is the slave. In practice,
18  when you are delegating it doesn't really matter which is master,
19  because all authoritative nameservers appear the same to the outside world)
20
21* Because you are a conscientious domain owner, you won't add the delegation
22  to host105.dns and host106.dns until they have correctly set up their
23  authoritative nameservice for the domain, and you've tested it.
24
25Now, because this pattern is repeated by everyone else in the class, it also
26means that:
27
28* You will receive delegation for a domain from host102.dns (for which you
29  will be the master)
30
31* You will receive delegation for another domain from host101.dns (for which
32  you will be slave, with host102.dns as the master)
33
34So you will be doing three different jobs!  You will have to:
35
36    1. set yourself up as master for the domain delegated from host102.dns
37    2. set yourself up as slave for the domain delegated from host101.dns
38    3. and delegate a subdomain of yours to host104.dns and host105.dns
39
40This means that a lot will be going on at once - so please follow the
41worksheet carefully!
42
43--------------------------------------------------------------------------
44
45Exercise parameters
46-------------------
47
48To start, please write the following missing information down on a piece of
49paper, numbered as (1) to (5). If it's not clear to you what needs to be done,
50please ask.
51
52     (1)  My machine is:     host______.dns
53 
54     (2)  I control domain:  _______________.dns
55 
56          (this is the domain you set up in the previous exercise, for which
57          your machine is the master)
58 
59     (3)  I am going to delegate this subdomain:
60 
61             _______________._______________.dns
62                                   (2)
63 
64          and I am going to delegate it to:
65 
66     (4)        host______.dns        (= myhost+1)   [master]
67 
68     (5)        host______.dns        (= myhost+2)   [slave]
69 
70          Wrap around to host101 and/or host101 if you run past the highest-
71          numbered host in the class (whoever has the highest number)
72
73Once you have done this, copy fields (1)-(5) from the worksheet for the
74machine numbered ONE BELOW YOU into fields (6)-(10) (write them down on
75paper). If you are host101, then the machine "below" you is the
76highest-numbered host in use in the class.
77
78     (6)  Their machine is:     host______.dns    (= myhost-1)
79 
80     (7)  They control domain:  _______________.dns
81 
82     (8)  They are going to delegate this subdomain:
83 
84             _______________._______________.dns
85                                   (7)
86 
87          and they are going to delegate it to:
88 
89     (9)        host______.dns        (= myhost)     [master] **
90 
91     (10)       host______.dns        (= myhost+1)   [slave]
92
93Next, copy fields (1)-(5) from the machine TWO BELOW YOU into fields
94(11)-(15)  (on paper)
95
96     (11) Their machine is:     host______.dns    (= myhost-2)
97 
98     (12) They control domain:  _______________.dns
99 
100     (13) They are going to delegate this subdomain:
101 
102             _______________._______________.dns
103                                  (12)
104 
105          and they are going to delegate it to:
106 
107     (14)       host______.dns        (= myhost-1)   [master]
108 
109     (15)       host______.dns        (= myhost)     [slave]  **
110
111--------------------------------------------------------------------------
112
113Step 1: Set up as master for domain (8)
114---------------------------------------
115
116You are going to be master for the domain given in (8). So the first step is
117to create a zonefile for this domain:
118
119    # vi /etc/namedb/master/__________.__________.dns
120
121    Or if you prefer PICO:
122
123    # pico /etc/namedb/master/__________.__________.dns
124                                     (8)
125
126    ... and insert the following contents in the file (don't include the
127    sections with numbers like '(9)' - these are just notes.
128
129
130
131     $TTL 10m
132     @       IN      SOA     host_____.dns. yourname.example.com. (
133                                (9)
134                                         2010070101
135                                         10m
136                                         10m
137                                         4w
138                                         10m )
139 
140             IN      NS      host_____.dns.
141                                (9)
142             IN      NS      host_____.dns.
143                                (10)
144 
145     www     IN      A       10.20.XXX.1    ; replace with your own IP
146
147
148
149
150Replace "yourname.example.com." with your modified E-mail address as in the
151previous exercise, and use the current YYYYMMDD00 as the serial number.
152
153Now validate the zonefile you have created:
154
155    # named-checkzone  __________.__________.dns  /etc/namedb/master/__________.__________.dns
156                                (8)                                                      (8)
157
158If this reports any errors, then fix them.
159
160Next, edit `/etc/namedb/named.conf` to configure bind as master for that zone
161using the zonefile you have created:
162
163    (Remember, if you don't know "vi", use "pico")
164
165    # vi /etc/namedb/named.conf
166
167    ... add this entry:
168
169
170
171     zone "__________.__________.dns" {
172                    (8)
173             type master;
174             file "master/__________.__________.dns";
175                                   (8)
176             allow-transfer { 10.20.XXX.1; };
177     };
178
179
180
181Replace 10.20.XXX.1 with the IP address of machine (10), which is going to be
182slave for this zone.
183
184Then validate your modified configuration file:
185
186    # named-checkconf
187
188Again, if this reports any errors then fix them. Now get your nameserver to
189reload its conf file and your new zone:
190
191    # rndc reload
192    # tail /var/log/messages
193
194Once again, check for any errors and fix them. Finally, test that your
195machine is giving out authoritative answers:
196
197
198    # dig +norec @10.20.XXX.1  __________.__________.dns.  soa
199                                      (8)
200
201
202replacing 10.20.XXX.1 with your own IP address. Check that you get a SOA
203response with the expected serial number, and the AA flag is present.
204
205Good - you are half way to getting delegation for this domain (it won't be
206done until your slave is set up properly)
207
208Step 2: Set up as slave for domain (13)
209---------------------------------------
210
211The host below you has set themselves up as master for the domain you wrote in
212(13), and will expect you to be the slave.
213
214So now edit `/etc/namedb/named.conf` to enable yourself as slave for this
215domain:
216
217    # pico /etc/namedb/named.conf
218    or
219    # vi /etc/namedb/named.conf
220
221    ... add this entry:
222
223
224
225     zone "__________.__________.dns" {
226                    (13)
227             type slave;
228             file "slave/__________.__________.dns";
229                                  (13)
230             masters { 10.20.XXX.1; };
231     };
232
233
234
235Replace 10.20.XXX.1 with the IP address of the master, the machine listed in
236space (14).
237
238Now validate your modified configuration file:
239
240    # named-checkconf
241
242If this reports any errors then fix them. Now get your nameserver to reload
243its conf file:
244
245    # rndc reload
246    # tail /var/log/messages
247
248Once again, check for any errors and fix them.
249
250If the machine below you has already set themselves up as master, then the
251zone transfer should take place within a few seconds. You can check this has
252happened by looking in `/var/log/messages` again, and checking whether the
253slave zone file has been created:
254
255    # ls /etc/namedb/slave/
256
257If not, then either the machine below you has not finished setting
258themselves up as master for the domain, or else they have not permitted
259access to your IP address to allow you to copy the zone. You can check using
260these commands:
261
262    # dig +norec @10.20.XXX.1  __________.__________.dns.  soa
263                     (14)             (13)
264
265    # dig @10.20.XXX.1  __________.__________.dns.  axfr
266              (14)             (13)
267
268The first should show you the SOA record with the correct serial number; the
269second should show you the entire contents of their zone file. If these are
270OK, then the zone transfer should take place within a few minutes.
271
272Step 3: Test before delegation of domain (3)
273--------------------------------------------
274
275You are now about to delegate the domain you chose in (3) to the machines
276listed in (4) and (5); here you are acting in the role of a domain registry.
277
278However, before you perform this delegation, you should check that they are
279both set up correctly, especially that they are both authoritative for the
280domain in question. Otherwise, you would be creating a lame delegation,
281which is not good.
282
283Test the master using the following command:
284
285    # dig +norec @host_____.dns.  __________.__________.dns.  soa
286                     (4)                            (3)
287
288Check:
289
290*   Is the response authoritative? (Flag AA)
291*   Does the SOA record list the correct host as the master?
292*   Are the nameserver (NS) records in the Authority section correct? There
293    should be two NS records, one giving the hostname of the master (4) and
294    one the hostname of the slave (5)
295*   Make a note of the zone serial number
296
297And then test the slave:
298
299    # dig +norec @host_____.dns.  __________.__________.dns.  soa
300                     (5)                            (3)
301Check:
302
303*   Is the response authoritative? (Flag AA)
304*   Does the zone serial number match that given by the master?
305*   Are the nameserver (NS) records in the Authority section correct?
306
307If any of these checks fail, explain what the problem was to the owners of
308those machines. Don't proceed until they have fixed the problems - and make
309sure you have *re-tested* the servers to ensure the problems really have
310been fixed.
311
312
313Step 4: Delegate domain (3)
314---------------------------
315
316This is the point at which you delegate the subdomain (3); all queries for
317this subdomain will be referred to the servers (4) and (5).
318
319Edit the zonefile for your domain (2):
320
321
322    # pico /etc/namedb/master/__________.dns
323    or
324    # vi /etc/namedb/master/__________.dns
325                               (2)
326
327    ... add these RRs (records)
328
329     __________  IN     NS     host_____.dns.
330         (3)                      (4)
331                 IN     NS     host_____.dns.
332                                  (5)
333
334Note: in the space marked (3) you just put the *subdomain* you have chosen, e.g.
335
336     elmo        IN     NS     host104.dns.
337                 IN     NS     host105.dns.
338
339This is because the domain origin is added automatically (e.g. if the
340zonefile is for `utopia.dns` then `elmo` becomes
341`elmo.utopia.dns`)
342
343You must also _increment_ the serial number in the SOA record at the top of
344the zone file; this must be done after every zone file change of course.
345
346Save your changes, then validate your modified zone file:
347
348    # named-checkzone  __________.dns  /etc/namedb/master/__________.dns
349                           (2)                                (2)
350If it's OK then reload:
351
352    # rndc reload
353    # tail /var/log/messages
354
355That's it! Now all you need to do is to test the new subdomain by doing a
356normal recursive lookup for a resource record within it, for example:
357
358    # dig www.__________.__________.dns.
359                       (3)
360
361This test should work from anywhere in the class. The query will be first
362referred to your nameservers, and then you will give out a referral to the
363nameservers (4) and (5) which hold the data for this zone.
364
365Step 5: Check you have received delegation for domain (8)
366---------------------------------------------------------
367
368Once you have got this far, you can check that you have received delegation
369for the domain (8) which you are master for. That is, make sure your slave
370is functioning correctly and has retrieved a copy of your zonefile; and talk
371to the domain owner on machine (6) to request delegation. Work along with
372them to ensure that any problems are ironed out. Once you have delegation,
373test that your new domain works correctly.
374
375Additional steps
376----------------
377
378If at any time you are being held up waiting for someone else to complete
379their part, then help them out.
380
381If you have completed everything successfully, then here are some additional
382things you can do.
383
384*   Add some more resource records to the zone file for domain (8), which
385    you control. Remember to increment the serial number.
386
387    Check that your slave has copied your modified zone file. Question:
388    how can you check that the slave has updated: (a) given console access
389    onto the slave machine itself, and (b) without any console access
390    to that machine?
391
392    Check that these new resource records work, by resolving them from
393    some other machine (one which is neither master nor slave for the zone)
394
395*   Find someone else who has also finished. Ask them to act as a third
396    nameserver (second slave) for your domain, for increased resilience.
397    Note that you'll have to change the NS records within the zone, and
398    you'll have to change the delegation from above to be consistent.
399
400*   Perform the 'dig +norec' test starting from the root servers, for
401    `www._____._____.dns` within your subdomain