homehowtokbslinksaboutcontactprojectsmusic

Index > Help Tutorials > Install and Configure DNS Server
In this example I am using following:
Hostname of DNS Server: dnsserv1
IP address of DNS Server: 192.168.15.1

Please adjust above to your environment, I am assuming that you are using static IP instead of dhcp.
You dont have to have static IP but for server it is good idea to have it
Following is the very basic configuration to create a DNS server using bind9. Start by updating the system if needed
sudo apt-get update && sudo apt-get upgrade
Now if you have not installed bind9 yet, install it
sudo apt-get install bind9 dnsutils
Now go to its directory
cd /etc/bind
Make changes to main configuration file
nano named.conf.local
and paste/add the following
// Do any local configuration here
// Consider adding the 1918 zones here, if they are not used in your
// organization
// include "/etc/bind/zones.rfc1918";
zone "mydomain.local" {
      type master; file "/etc/bind/db.mydomain.local";
};
zone "15.168.192.in-addr.arpa" {
     type master; file "/etc/bind/db.192.168.15";
};
Now creat zone file, start with forward zone
nano db.mydomain.local
and paste/add the following information in that file
$TTL 604800
@ IN SOA dnsserv1.mydomain.local. admin.mydomain.local. (
          10 ; Serial
          604800 ; Refresh
          86400 ; Retry
          2419200 ; Expire
          604800 ; Negative Cache Time To Live
          )

@         IN    NS       dnsserv1.mydomain.local.
@         IN    A        172.168.15.1
@         IN    MX   10  dnsserv1.mydomain.local.
dnsserv1  IN    A        172.168.15.1
www       IN    CNAME    dnsserv1
xp-box    IN    A        172.168.15.2
Save the above file and exit out of it, now lets create reverse zone for above forward zone
nano db.172.168.15
You can name it any way it does not really matter, paste/type the following information in it
$TTL 604800
@ IN SOA dnsserv1.mydomain.local. admin.mydomain.local. (
       10 ; Serial
       604800 ; Refresh
       86400 ; Retry
       2419200 ; Expire
       604800 ; Negative Cache Time To Live
       )

@    IN    NS    dnsserv1.mydomain.local.
1    IN    PTR    dnsserv1.mydomain.local.
2    IN    PTR    xp-box.mydomain.local.
That is pretty much it and shiny DNS Server is ready, you can check it by running following command
named-checkzone mydomain.local /etc/bind/db.mydoamin.local
look for the error if any and correct them. If no error(s) then charm! we did it so go ahead and restart your dns server
sudo /etc/init.d/bind9 restart
or
service bind9 restart
Forward the DNS queries your server can not resolve to your ISP, you may not need them.
nano /etc/bind/named.conf.options
and change the following
// forwarders {
        //      0.0.0.0;
        // };
to
 forwarders {
              20.20.20.20;
         };
replace 20.20.20.20 with your ISP's DNS Server IP address. Now just to be safe restart DNS Server, you don't have to though
sudo /etc/init.d/bind9 restart
or
sudo service bind9 restart
Now change your dns setting in /etc/resolv.conf file something like this
sudo nano /etc/resolv.conf
You entries should look like following of course with your domain information
search mydomain.local
nameserver 172.168.15.1
Save the file and try to ping some external addresses like yahoo.com, google.com etc. If ping worked every thing is good and you are done !

Enjoy your new DNS server!

Some useful command for DNS testing
dig mydomain.local
dig -x mydomain.local
dig 172.168.15.1
nslookup mydomain.local
nslookup 172.168.15.1
nslookup dnsserv1
nslookup xp-box
nslookup dnsserv1.mydomain.local
nslookup xp-box.mydomain.local
dig mx mydomain.local