| 1 | DNS Exercise - Part II |
|---|
| 2 | ====================== |
|---|
| 3 | |
|---|
| 4 | In this exercise, you will *delegate* a subdomain of your own domain. |
|---|
| 5 | |
|---|
| 6 | In order to keep things simple, it will work like this: each machine will |
|---|
| 7 | delegate a subdomain to the next host along (which will be the master) and the |
|---|
| 8 | next one after that (which will be the slave). |
|---|
| 9 | |
|---|
| 10 | Example: |
|---|
| 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 | |
|---|
| 25 | Now, because this pattern is repeated by everyone else in the class, it also |
|---|
| 26 | means 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 | |
|---|
| 34 | So 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 | |
|---|
| 40 | This means that a lot will be going on at once - so please follow the |
|---|
| 41 | worksheet carefully! |
|---|
| 42 | |
|---|
| 43 | -------------------------------------------------------------------------- |
|---|
| 44 | |
|---|
| 45 | Exercise parameters |
|---|
| 46 | ------------------- |
|---|
| 47 | |
|---|
| 48 | To start, please write the following missing information down on a piece of |
|---|
| 49 | paper, numbered as (1) to (5). If it's not clear to you what needs to be done, |
|---|
| 50 | please 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 | |
|---|
| 73 | Once you have done this, copy fields (1)-(5) from the worksheet for the |
|---|
| 74 | machine numbered ONE BELOW YOU into fields (6)-(10) (write them down on |
|---|
| 75 | paper). If you are host101, then the machine "below" you is the |
|---|
| 76 | highest-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 | |
|---|
| 93 | Next, 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 | |
|---|
| 113 | Step 1: Set up as master for domain (8) |
|---|
| 114 | --------------------------------------- |
|---|
| 115 | |
|---|
| 116 | You are going to be master for the domain given in (8). So the first step is |
|---|
| 117 | to 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 | |
|---|
| 150 | Replace "yourname.example.com." with your modified E-mail address as in the |
|---|
| 151 | previous exercise, and use the current YYYYMMDD00 as the serial number. |
|---|
| 152 | |
|---|
| 153 | Now validate the zonefile you have created: |
|---|
| 154 | |
|---|
| 155 | # named-checkzone __________.__________.dns /etc/namedb/master/__________.__________.dns |
|---|
| 156 | (8) (8) |
|---|
| 157 | |
|---|
| 158 | If this reports any errors, then fix them. |
|---|
| 159 | |
|---|
| 160 | Next, edit `/etc/namedb/named.conf` to configure bind as master for that zone |
|---|
| 161 | using 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 | |
|---|
| 181 | Replace 10.20.XXX.1 with the IP address of machine (10), which is going to be |
|---|
| 182 | slave for this zone. |
|---|
| 183 | |
|---|
| 184 | Then validate your modified configuration file: |
|---|
| 185 | |
|---|
| 186 | # named-checkconf |
|---|
| 187 | |
|---|
| 188 | Again, if this reports any errors then fix them. Now get your nameserver to |
|---|
| 189 | reload its conf file and your new zone: |
|---|
| 190 | |
|---|
| 191 | # rndc reload |
|---|
| 192 | # tail /var/log/messages |
|---|
| 193 | |
|---|
| 194 | Once again, check for any errors and fix them. Finally, test that your |
|---|
| 195 | machine is giving out authoritative answers: |
|---|
| 196 | |
|---|
| 197 | |
|---|
| 198 | # dig +norec @10.20.XXX.1 __________.__________.dns. soa |
|---|
| 199 | (8) |
|---|
| 200 | |
|---|
| 201 | |
|---|
| 202 | replacing 10.20.XXX.1 with your own IP address. Check that you get a SOA |
|---|
| 203 | response with the expected serial number, and the AA flag is present. |
|---|
| 204 | |
|---|
| 205 | Good - you are half way to getting delegation for this domain (it won't be |
|---|
| 206 | done until your slave is set up properly) |
|---|
| 207 | |
|---|
| 208 | Step 2: Set up as slave for domain (13) |
|---|
| 209 | --------------------------------------- |
|---|
| 210 | |
|---|
| 211 | The 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 | |
|---|
| 214 | So now edit `/etc/namedb/named.conf` to enable yourself as slave for this |
|---|
| 215 | domain: |
|---|
| 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 | |
|---|
| 235 | Replace 10.20.XXX.1 with the IP address of the master, the machine listed in |
|---|
| 236 | space (14). |
|---|
| 237 | |
|---|
| 238 | Now validate your modified configuration file: |
|---|
| 239 | |
|---|
| 240 | # named-checkconf |
|---|
| 241 | |
|---|
| 242 | If this reports any errors then fix them. Now get your nameserver to reload |
|---|
| 243 | its conf file: |
|---|
| 244 | |
|---|
| 245 | # rndc reload |
|---|
| 246 | # tail /var/log/messages |
|---|
| 247 | |
|---|
| 248 | Once again, check for any errors and fix them. |
|---|
| 249 | |
|---|
| 250 | If the machine below you has already set themselves up as master, then the |
|---|
| 251 | zone transfer should take place within a few seconds. You can check this has |
|---|
| 252 | happened by looking in `/var/log/messages` again, and checking whether the |
|---|
| 253 | slave zone file has been created: |
|---|
| 254 | |
|---|
| 255 | # ls /etc/namedb/slave/ |
|---|
| 256 | |
|---|
| 257 | If not, then either the machine below you has not finished setting |
|---|
| 258 | themselves up as master for the domain, or else they have not permitted |
|---|
| 259 | access to your IP address to allow you to copy the zone. You can check using |
|---|
| 260 | these 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 | |
|---|
| 268 | The first should show you the SOA record with the correct serial number; the |
|---|
| 269 | second should show you the entire contents of their zone file. If these are |
|---|
| 270 | OK, then the zone transfer should take place within a few minutes. |
|---|
| 271 | |
|---|
| 272 | Step 3: Test before delegation of domain (3) |
|---|
| 273 | -------------------------------------------- |
|---|
| 274 | |
|---|
| 275 | You are now about to delegate the domain you chose in (3) to the machines |
|---|
| 276 | listed in (4) and (5); here you are acting in the role of a domain registry. |
|---|
| 277 | |
|---|
| 278 | However, before you perform this delegation, you should check that they are |
|---|
| 279 | both set up correctly, especially that they are both authoritative for the |
|---|
| 280 | domain in question. Otherwise, you would be creating a lame delegation, |
|---|
| 281 | which is not good. |
|---|
| 282 | |
|---|
| 283 | Test the master using the following command: |
|---|
| 284 | |
|---|
| 285 | # dig +norec @host_____.dns. __________.__________.dns. soa |
|---|
| 286 | (4) (3) |
|---|
| 287 | |
|---|
| 288 | Check: |
|---|
| 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 | |
|---|
| 297 | And then test the slave: |
|---|
| 298 | |
|---|
| 299 | # dig +norec @host_____.dns. __________.__________.dns. soa |
|---|
| 300 | (5) (3) |
|---|
| 301 | Check: |
|---|
| 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 | |
|---|
| 307 | If any of these checks fail, explain what the problem was to the owners of |
|---|
| 308 | those machines. Don't proceed until they have fixed the problems - and make |
|---|
| 309 | sure you have *re-tested* the servers to ensure the problems really have |
|---|
| 310 | been fixed. |
|---|
| 311 | |
|---|
| 312 | |
|---|
| 313 | Step 4: Delegate domain (3) |
|---|
| 314 | --------------------------- |
|---|
| 315 | |
|---|
| 316 | This is the point at which you delegate the subdomain (3); all queries for |
|---|
| 317 | this subdomain will be referred to the servers (4) and (5). |
|---|
| 318 | |
|---|
| 319 | Edit 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 | |
|---|
| 334 | Note: 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 | |
|---|
| 339 | This is because the domain origin is added automatically (e.g. if the |
|---|
| 340 | zonefile is for `utopia.dns` then `elmo` becomes |
|---|
| 341 | `elmo.utopia.dns`) |
|---|
| 342 | |
|---|
| 343 | You must also _increment_ the serial number in the SOA record at the top of |
|---|
| 344 | the zone file; this must be done after every zone file change of course. |
|---|
| 345 | |
|---|
| 346 | Save your changes, then validate your modified zone file: |
|---|
| 347 | |
|---|
| 348 | # named-checkzone __________.dns /etc/namedb/master/__________.dns |
|---|
| 349 | (2) (2) |
|---|
| 350 | If it's OK then reload: |
|---|
| 351 | |
|---|
| 352 | # rndc reload |
|---|
| 353 | # tail /var/log/messages |
|---|
| 354 | |
|---|
| 355 | That's it! Now all you need to do is to test the new subdomain by doing a |
|---|
| 356 | normal recursive lookup for a resource record within it, for example: |
|---|
| 357 | |
|---|
| 358 | # dig www.__________.__________.dns. |
|---|
| 359 | (3) |
|---|
| 360 | |
|---|
| 361 | This test should work from anywhere in the class. The query will be first |
|---|
| 362 | referred to your nameservers, and then you will give out a referral to the |
|---|
| 363 | nameservers (4) and (5) which hold the data for this zone. |
|---|
| 364 | |
|---|
| 365 | Step 5: Check you have received delegation for domain (8) |
|---|
| 366 | --------------------------------------------------------- |
|---|
| 367 | |
|---|
| 368 | Once you have got this far, you can check that you have received delegation |
|---|
| 369 | for the domain (8) which you are master for. That is, make sure your slave |
|---|
| 370 | is functioning correctly and has retrieved a copy of your zonefile; and talk |
|---|
| 371 | to the domain owner on machine (6) to request delegation. Work along with |
|---|
| 372 | them to ensure that any problems are ironed out. Once you have delegation, |
|---|
| 373 | test that your new domain works correctly. |
|---|
| 374 | |
|---|
| 375 | Additional steps |
|---|
| 376 | ---------------- |
|---|
| 377 | |
|---|
| 378 | If at any time you are being held up waiting for someone else to complete |
|---|
| 379 | their part, then help them out. |
|---|
| 380 | |
|---|
| 381 | If you have completed everything successfully, then here are some additional |
|---|
| 382 | things 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 |
|---|