Thursday, December 15, 2011

Install DNS Server in Debian 6.0 (Squeeze)

The Internet maintains two principal namespaces, the domain name hierarchy and the Internet Protocol (IP) address spaces. The Domain Name System maintains the domain name hierarchy and provides translation services between it and the address spaces. Internet name servers and a communication protocol implement the Domain Name System. A DNS name server is a server that stores the DNS records for a domain name, such as address (A) records, name server (NS) records, and mail exchanger (MX) records (see also list of DNS record types), a DNS name server responds with answers to queries against its database (Source: en.wikipedia.org)

Installation
Bind9 (Berkeley Internet Name Domain Versi 9) is one of popular linux application as DNS Server, and almost all linux distribution use it. Over that, you can configure it easily, especially for beginner.
# apt-get install bind9
Configuration
That are important file in DNS Server configuration :
a. /etc/bind/named.conf
b. file forward
c. file reverse
d. /etc/resolv.conf
Make Domain Zone
First, Let's edit configuration file for forward and Reserve, on file named.conf or named.conf.local. Then, add this script :
# vim /etc/bind/named.conf
#. . .
zone "26maret1991.net" {                    //Your Domain Zone
type master;
file "db.26maret1991";                        //lokasi file FORWARD, default di /var/cache/bind/
};
zone "192.in-addr.arpa" {                   //first IP Addrees block
type master;
file "db.192";                                      //Reverse location, default in /var/cache/bind/
};
include "/etc/bind/named.conf.local";               //make file named.conf.local in progress
File Forward
Function of Forward are convert from DNS to IP Address. Make configuration file for foward from DNS. Because the configuratiaon are to many, then we can copy that file from the default.
# cd /etc/bind/
# cp db.local /var/cache/bind/db.26maret
 Edit this file :
# vim /var/cache/bind/db.26maret
 $TTL 604800
@ IN      SOA       debian.edu. root.debian.edu. (

2                      ; Serial
604800            ; Refresh
86400              ; Retry
2419200          ; Expire
604800 )          ; Negative Cache TTL
;
@                IN         NS       debian.edu.     ;add “node” in end of domain
@                IN          A        192.168.10.1

File Reverse
function of Reverse are for convert the IP Address to DNS. For example, when we type the IP Address (http://192.168.10.1) on the Web Browser. Then will be automatically redirect to address (www.26maret1991.net).
# cp db.127 /var/cache/bind/db.192
Edit this file :
# vim /var/cache/bind/db.192
$TTL         604800
@               IN         SOA         debian.edu. root.debian.edu. (
                                                          1                 ; Serial
                                                     604800            ; Refresh
                                                      86400             ; Retry
                                                    2419200           ; Expire
                                                    604800 )           ; Negative Cache TTL
;
@               IN    NS          debian.edu.           ;don't forget “node”
1.10.168    IN    PTR        debian.edu.           ;3rd IP block, and rotate it.
Add Dns-name-server
Add dns-name-server in resolv.conf file configuration. If you want to access from localhost.
# vim /etc/resolv.conf
then add this :
search 26maret1991.net
nameserver 192.168.10.1
And the last, please restart Bind9 from Daemon.
# /etc/init.d/bind9 restart
Test Your DNS Server
Test the DNS Server are success or failed, use Nslookup from localhost computer or client.
# nslookup 192.168.10.1
 Then will be appear
Server     : 192.168.10.1
Address  : 192.168.10.1#53
1.10.168.192.in-addr.arpa name = debian.26maret1991.net.
Or Use this command.
# nslookup debian.edu
Then will be appear
Server    : 192.168.10.1
Address : 192.168.10.1#53
Name     : debian.edu
If that appeared like this.
Server : 192.168.10.1
Address : 192.168.10.1#53
** server can't find debian.edu.debian.edu: SERVFAIL
There is some script are wrong. You can check it in all configuration script like named.conf, db.26maret1991, and db.192.

No comments: