Appendix 6

 Appendix 6
2.2.4 DNS

     Before going over details of BIND(Berkley Internet Domain Name) system let us tune our resolver to a name server available to our upstream editing the file /etc/resolv.conf like:

-------- /etc/resolv.conf file starts here -------
domain inf.yatsushiro-nct.ac.jp
nameserver 202.251.39.129
# Yes that's luna, our Upstream Name Server
-------- /etc/resolv.conf file ends here ---------

maple@junan:/usr/share/dict{1039}% nslookup
Default Server: luna.inf.yatsushiro-nct.ac.jp
Address: 202.251.39.129
> maple
Server: luna.inf.yatsushiro-nct.ac.jp
Address: 202.251.39.129
Name: maple.inf.yatsushiro-nct.ac.jp
Address: 202.251.39.12
> luna
Server: luna.inf.yatsushiro-nct.ac.jp
Address: 202.251.39.129
Name: luna.inf.yatsushiro-nct.ac.jp
Address: 202.251.39.129
> exit

So, the resolver looks at the the upstream nameserver and acts accordingly. But we are going to setup our nameserver here. We would be using BIND to setup our nameserver. It is bundled with the FreeBSD, so it is already installed in your machine. We are going to ommit the installing process here as it is more or less same as above. Here we will concentrate on the different configuration files.
     The first step in setting up our nameserver will be to put DNS data in necessary files. There are mainly few kinds of files:

     db.maple: maps host names to addresses.
     db.191.168.0: maps addresses back to host names
     db.cache: overhead file. Each server must have them. More or less same.
     db.127.0.0: same as above. Loopback address is located here.
     named.boot: the file to tie up all the data files together.

We will discuss these files below but we will unfortunately start with a complete file rather than a blank file. So, here is the db.maple file after completion:

----------------- start of db.maple file -------------------

----------------- end of db.maple file -------------------

The first entry in each file is SOA(Source of Authority) records. We should have been putting here the domain we are going to control, i.e., ant.yatsushiro-nct.ac.jp.(Yes, the trailing dot must be there) ? instead we put a symbol in this place. '@' notation states that
"I'm same as the domain name of the origin", so the real meaning of '@' will be found from the following record IN SOA. The IN class stands for Internet and the first name after SOA is the name of the primary name server(maple.ant.yatsushiro-nct.ac.jp). The second name is the mail address of the person who maintains these data. As you might wonder about the e-mail address you should notice that you have to replace first dot with to actually send a mail to the maintainer. The parentheses allow records to span over lines which is good for human readers. Serial number is for secondary name servers to update their local database. You can start counting from 1 or from any other counting method but make sure that newer updates get higher serial numbers. Refresh is given in seconds, so 10800 seconds should be 3 hours, in the span of 3 hours secondary name servers checks the primary name servers for any new updates and act accordingly. Retry is also given in seconds which determines how long secondary name servers should wait before retrying a failed session. 1800 seconds, i.e. 30 minutes is reasonable. Expire determines the valid period of the data available at secondary name server. Minimum gives the minimum time to live period for cached data. It should be smaller if your data changes frequently otherwise it should be bigger. Next comes the NS records.

IN NS maple.ant.yatsushiro-nct.ac.jp. ; primary

It indicates that there is a name server for our domain ant.yatsushiro-nct.ac.jp. We can add other name servers with multiple lines here too. There is another advantage of making maple name server for our domain ----- it is acting as a router which means that other networks can access this host too. The omitted line is a little bit complicated to explain in detail, just to point out a little is that it takes care of the mails with the domain name attached.

IN MX 10 maple.ant.yatsushiro-nct.ac.jp. ; mail

Now db.192.168.0 file which maps back addresses to host names:

----------------- start of db.192.168.0 file -------------------

----------------- end of db.192.168.0 file -------------------

As it was mentioned earlier it maps back addresses to host names. Actually we should have been putting lines like:

12.0.168.192.in-addr.arpa. IN PTR momo.ant.yatsushiro-nct.ac.jp.

instead of:

12 IN PTR momo.ant.yatsushiro-nct.ac.jp.

But by virtue of '@' notation we can replace '12.0.168.192.in-addr.arpa.' with a last network number only - that's quite useful for us!
Now the loopback address file db.127.0.0:

----------------- Start of db.127.0 file -------------------
----------------- end of db.127.0.0 file -------------------

It covers the loopback network used by a lot of programs. A name server would work without this file but a lookup at 127.0.0.1 would fail. Hence, the necessity of db.127.0.0 file. It should be more or less same anywhere.
db.cache file holds the information of root domains. This file should be more or less same for anywhere. Though this file doesn't change frequently you are always advised to get the newer updated version from ftp.rs.internic.net with anonymous ftp.

----------------- Start of db.cache file -------------------
----------------- End of db.cache file -------------------

At last the named.boot file. It is the file that puts together all the files described above. Here is the completed named.boot file:
----------------- Start of named.boot file -------------------

----------------- end of named.boot file -------------------

The first valid line indicates where all the data files are located. Here, the location is in /etc/namedb, it can be anywhere, though a separate directory is appreciated. The following lines contains three fields: first column with a word 'primary', second column is the domain the server authoritative for, third column is the data filename. db.cache is read by the line:

cache . db.cache

You can see another line starting with the word 'forwards'. This line tells the name server to query the host(202.251.33.1, i.e., our school name server) when it fails to find the answer in it's cache. If a forwarder takes longer time to reply, our name server will try to perform it itself.
     So, we are now settled to with our data files and with our boot file. We can now simply run:

maple# /usr/sbin/named -b /etc/namedb/named.boot

It should work nicely. If you get problems running the name server see the error messages at the /var/log/messages file. It will perhaps give you a few details. Now before trying with our new name server we should fix our /etc/resolv.conf file first. The following lines should work just fine:

maple@junan:/etc/namedb{1021}% cat /etc/resolv.conf
domain ant.yatsushiro-nct.ac.jp
nameserver 192.168.0.3

Now we are ready to test our name server:

maple@junan:/etc/namedb{1023}% nslookup
Default Server: maple.ant.yatsushiro-nct.ac.jp
Address: 192.168.0.3
> maple
Server: maple.ant.yatsushiro-nct.ac.jp
Address: 192.168.0.3
Name: maple.ant.yatsushiro-nct.ac.jp
Addresses: 192.168.0.3, 202.251.39.12
> mapletown
Server: maple.ant.yatsushiro-nct.ac.jp
Address: 192.168.0.3
Name: mapletown.ant.yatsushiro-nct.ac.jp
Address: 192.168.0.16
> www.freebsd.org
Server: maple.ant.yatsushiro-nct.ac.jp
Address: 192.168.0.3
Non-authoritative answer:
Name: freefall.freebsd.org
Address: 204.216.27.21
Aliases: www.freebsd.org

It seems like working nicely!

| Home | Introduction | An Overview of Our Network | System Administration | Security | Conclusion | Acknowledgements | References | Appendix 1 | Appendix 2 | Appendix 3 | Appendix 4 | Appendix 5 | Appendix 6 | Appendix 7 | Appendix 8 | Appendix 9 | Appendix 10

This page is maintained by:
jchakma@yahoo.com