Network Startup Resource Center                            http://www.nsrc.org/

                        DNS Exercise - Delegation
                        -------------------------

In this exercise, we will create and delegate a new domain "mytld". 

Fo this exercize "mytld" must be of the form:

  what-ever-you-choose.dnstest.gov.co

This will allow it to be delegated from a live zone.

You will create a master nameservice on your own machine, and someone else
will provide slave service. Then you will ask the administrator for the
domain above you (the root) to delegate your domain to you.

Note: the following should be done as the "root" superuser.

Firstly, note that your hostname is configured correctly
on your machine.  Check that it is configured correctly by
using the 'hostname' command - e.g. on auth1.grpXX.ws.nsrc.org, if you type:

 # hostname

You should see:

  auth1.grpXX.ws.nsrc.org

If not, then configure your server with its name: e.g. for
	auth1.grp25.ws.nsrc.org, type:

 # hostname auth1.grp25.ws.nsrc.org

Remember to replace "grpXX" with the the proper group number!

Edit the file /etc/rc.conf (using "vi" or "ee", i.e.: ee /etc/rc.conf),
and update the "hostname":

  hostname="auth1.grpXX.ws.nsrc.org"

In the file /etc/hosts, you should see a line:

  10.10.XX.1   auth1.grpXX auth1.grpXX.ws.nsrc.org


Exercise
--------

*   Choose a new domain, write it down somewhere

    i.e.: "mytld" or "EARTH" - whatever you feel like.

    (Do NOT choose any of the PC names, e.g. `auth1.grpXX`, as your subdomain)

    This could for example be the name of your country code, country name,
	company name, etc...  but REMEMBER that someone might pick the same name!
	First come, first serve.

*   Find someone who will agree to be slave for your domain. Please find someone
    across the room from you (not at your table) (Remember RFC2182:  secondaries
    must be on remote networks but here we work on a flat network). You can have 
    more than one slave if you wish.

*   Create your zone file in `/etc/namedb/master/mytld`
    (where mytld is your chosen domain) -- you can pretty much
    "copy and paste" the section below -- but remember to update
    the XX with your IP:

  ***   Remember, you will need to become root to create this file,
  ***   so, e.g.
  ***
  ***     $ cd /etc/namedb/master
  ***     $ sudo vi mytld
  ***
  ***   (feel free to use another editor instead of vi, e.g. joe, ee)

- - - - - - - - - - - - - cut below - - - - - - - - - - - -

$TTL 2m
@       IN      SOA     auth1.grpXX.ws.nsrc.org. your@email.address. (
                        2012022301    ; Serial
                        10m           ; Refresh
                        5m            ; Retry
                        1d            ; Expire
                        2m )          ; Negative

        IN      NS      auth1.grpXX.ws.nsrc.org.   ; master
        IN      NS      auth1.grpYY.ws.nsrc.org.   ; slave

www     IN      A       10.10.XX.1             ; your own IP

- - - - - - - - - - - - - cut above - - - - - - - - - - - -

    Replace `your@email.address.` with your home E-mail address. ( Note
    "your" cannot have dots in it. )

	XX and YY are the IP of your group, and your slave's, respectively.
	
    We have chosen purposely low values for TTL, refresh, and retry to make
    it easier to fix problems in the classroom. For a production domain you
    might use higher values.

*   Edit `/etc/namedb/named.conf` and do the following:

  ***   Remember, you will need to become root to edit this file,
  ***   so, e.g.
  ***
  ***     $ cd /etc/namedb
  ***     $ sudo vi named.conf
  ***
  ***   (feel free to use another editor instead of vi, e.g. joe, ee)

    - If it is still there, REMOVE the following line:

         listen-on { 127.0.0.1; };

    ... and add another line in the options section:

        allow-query { any; };

    ... so that your nameserver will now answer queries from the network

    - If there is a section covering the root zone ".", remove it.

    - Add a section to configure your machine as master for
      your domain, by adding something like this at the end
	  (the bottom) of the file:

      zone "mytld" {
        type master;
        file "/etc/namedb/master/mytld";
      };

    Pay attention to the ';' and '}' !

*   Check that your config file and zone file are valid:

        # named-checkconf
        # named-checkzone mytld /etc/namedb/master/mytld

    * If there are any errors, correct them ! *

*   If this is not already done, enable named in your server's configuration,
    by editing the file /etc/rc.conf and adding, if this is not already done:

     ** Remember, again, you need to be root to edit this file

        named_chrootdir=""
        named_enable="YES"

    - Then start/restart named with

        # service named restart

    Check the result with

        # tail /var/log/messages

	Verify with dig that mytld is now configured on your host:

        # dig @10.10.XX.1 mytld. NS

	Where "XX" is the address of your machine.

        You can also check the nameserver status using rndc:

        # rndc status

    - If there are any errors, correct them. Some configuration errors can
    cause the daemon to die completely, in which case you may have to
    start it again:

        # /etc/rc.d/named restart

*   Assist your slaves to configure themselves as slave for your domain, and
    configure yourself as a slave if asked to do so by another table.

    Here is most of what you need to add to the end of the named.conf file:

      zone "mytld" { 
         type slave;
         masters { 10.10.XX.1; };
         file "/etc/namedb/slave/mytld";
      };

	... where XX is the group where the master is located.

    If you have changed your `named.conf` so that you are a slave for
    someone else, make sure that there are no errors in `/var/log/messages` after
    you restart your nameserver.

    You will need a slave directory with proper permissions and ownership where
    bind can write the zone file received from the master.

*   Check that you and your slaves are giving authoritative answers for
    your domain:

        # dig +norec @10.10.XX.1 mytld. SOA
        # dig +norec @10.10.YY.1 mytld. SOA

    Check that you get an AA (authoritative answer) from both, and that
    the serial numbers match.

*   Now you are ready to request delegation.  Go to https://rzm.dnssek.org 
    and log in with mytld as "Username:" and password provided by instructor. 
    Under "Name Server Details for mytld." click "Edit" and enter "Name Server" 
    such as auth1.grpXX.ws.nsrc.org. and its corresponding IP address 10.10.XX.1.
    Then click "Add NS Record".  Do this for any other slave NS record as well. 
    Once finished, click "Commit" and inform the instructor that you have
    completed this step.

*   Your entry must meet the following requirements:

    - Your nameservers are all authoritative for your domain
    - They all have the same SOA serial number
    - The NS records within the zone match the list of servers you are
      requesting delegation for
    - The slave(s) are across the room from you :)

	=> This is called policy!

*   Once you have delegation, try to resolve www.mytld:

    - On your own machine
    - On someone else's machine (who is not slave for you):

    # dig @10.10.XX.1 www.mytld       (where mytld is your domain)

*   After a few minutes, try to resolve www.mytld using the general resolver
    at 10.10.0.230:

    # dig www.mytld

*   Add a new resource record to your zone file. Remember to update the
    serial number. Check that your slaves have updated. Try resolving this
    new name. 

    # edit /etc/namedb/master/mytld
    # rndc reload mytld
    # dig @10.10.XX.1 your-new-RR.mytld

