Pages

Friday, August 31, 2012

DNS setup in BSD machine

     Earlier I have written a blog about setting up DNS server in CentOS. You can find that here. And today I was given a task to do the same in BSD machine. wtf! Even BSD is an UNIX variant, it is not Linux. So the problem it will not have much different but a little. We have find that little one. Like earlier, I didn't find any simple method to setup dns.

     The concept is same as we did in Linux. Need to install bind. Then edit named.conf. And write a database file. I am not going to explain every steps. So just spend some 10 minutes with the page I mentioned above. Of course 10 minutes is enough to finish that article.

Install bind:
     If you have connected your BSD machine with Internet, It will be much easy. I didn't connected. If you have connected,
#cd /usr/ports/dns/bind94/
#make configure
select the options you want in the menu shown. Ans click ok. Thats all you have done.

     In case you are not having Internet like me(poor guy right?), download bind-9.4-ESV.tar.gz and bind-9.4-ESV.tar.gz.asc and copy that to your BSD machine on the location /usr/ports/distfiles. Now run the above two commands. Thats all. You thought of more complex steps. You are not supposed to expect complex things from this blog. Because basically I am a somberi.

Edit named.config
     Just copy and paste the following in the file /etc/namedb/named.conf

zone "example.org" {
     type master;
     file "/etc/namedb/master/example.org.db";
};
    Change the name and file path as per your requirement. Atleast read that above mentioned article now. You can have a little understanding of this file. Anyway you wish :@

Edit database file
       Copy and paste the following /etc/namedb/master/example.org.db"
$TTL    3600
example.org.  IN  SOA  example.org  hostmaster.example.org. ( 
    200
      112000
      15000
      312000
      22000 )

example.org.  IN  NS  ns1.example.org.

ns1.example.org.  IN  A  10.0.0.1

example.org.  IN  A  10.10.10.10
one.example.org.  IN  A  5.3.3.3
six.example.org.  IN  AAAA  3fff::e
six.example.org.  IN  AAAA  fe80::10

Alter this as per you requirement. Now you have no chance. You should read that article if you want to really alter anything here.

Some touch things and start the engine
     Now open /etc/rc.conf and the line named_enable="YES" at the end.


     Set your DNS server to the local host. Open /etc/resolv.conf and add nameserver 127.0.0.1. Or the IP may be any IP you assigned to your machine. It also can be an IPv6 address.
#echo "nameserver <ip_addr>" >/etc/resolv.conf
Okey. Steps are over. start it.
#service named start
 Whatever error it throws, don't care. Just check it by doing a look-up. You want to know the command to do a look-up? Then I am so rude I won't help you.

Troubleshooting
     If it is not working, try after rebooting the machine.
     If you make any change in the configuration file or the database file, you need to restart the dns server. you can simply use #service named restart. But in my case, it doesn't work. So #killall named and once again start the dns server with #service named start
 
    And you really want more and you have time and patience, read this. I referred this page to set up DNS server in my machine and write this article ;). I said I referred not read!

No comments:

Post a Comment