Wednesday, February 22, 2012

Configuring simple DNS using bind or named

Advertisements


Configuring simple DNS using bind or named

I was searching for a simple DNS implementation using bind. But couldnt find one. So I'm posting this here. Here we are configuring dns for a domain lap.work

Server side configuration :
Install the bind and other needed packages
yum install bind-chroot bind bind-devel bind-utils caching-nameserver

Change the directory to /var/named/chroot/etc/ as we have installed chroot package. The ROOTDIR of named changed to /var/named/chroot
#cd /var/named/chroot/etc/

Create a named.conf using the sample files created by caching-nameserver
cat named.* > named.conf

Edit the named.conf as follows
[root@server ~]# cat /var/named/chroot/etc/named.conf
options {
        directory       "/var/named";
};

zone "lap.work" IN {
        type master; // This is the forward zone declaration for the domain lap.work
        file "lap.work.zone";
};

zone "137.168.192.in-addr.arpa" IN {
        type master; // This is the reverse zone declaration for the domain lap.work
        file "lap.work.local";
};
[root@server ~]#

Now creating the forward and reverse zone files.
[root@server ~]# cd /var/named/chroot/var/named/
cp localdomain.zone lap.work.zone
cp named.local lap.work.local

Create the forward zone as follows
[root@server named]# cat  lap.work.zone
$TTL    86400
@               IN SOA  lap.work. root (
                                        43              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum
                IN NS           ns1.lap.work.
                IN MX  10       work1.lap.work.

www             IN A            192.168.137.10
ftp             IN A            192.168.137.10
mail            IN A            192.168.137.10
work1           IN A            192.168.137.10
ns1             IN A            192.168.137.10
[root@server named]#

Reverse zone file as
[root@server named]# cat  lap.work.local
$TTL    86400
@       IN      SOA     lap.work. root.lap.work.  (
                                      1997022701 ; Serial
                                      28800      ; Refresh
                                      14400      ; Retry
                                      3600000    ; Expire
                                      86400 )    ; Minimum
         IN      NS      lap.work.
10       IN      PTR     work1.lap.work.
[root@server named]#

Change the permissions so that the following files belongs to the group named
[root@server named]# chown root.named /var/named/chroot/etc/named.conf
[root@server named]# chown root.named /var/named/chroot/var/named/lap.work.zone
[root@server named]# chown root.named /var/named/chroot/var/named/lap.work.local

start the named service.
[root@server named]# /etc/init.d/named start
Starting named:                                            [  OK  ]
[root@server named]#

client side configuration:
Edit the resolv.conf as follows.
[root@work1 ~]# cat /etc/resolv.conf
nameserver 192.168.137.100
[root@work1 ~]#

Testing the server using host and nslookup commands
[root@work1 ~]# host work1.lap.work
work1.lap.work has address 192.168.137.10
[root@work1 ~]# host -i 192.168.137.10
10.137.168.192.in-addr.arpa domain name pointer work1.lap.work.
[root@work1 ~]# nslookup work1.lap.work
Server:         192.168.137.100
Address:        192.168.137.100#53
Name:   work1.lap.work
Address: 192.168.137.10
[root@work1 ~]# nslookup 192.168.137.10
Server:         192.168.137.100
Address:        192.168.137.100#53
10.137.168.192.in-addr.arpa     name = work1.lap.work.
[root@work1 ~]#

1 comment:

  1. hhey boss tell me how to use the GUI interface for DNS confguration, cuz i really need such type of graphical service, n m configuring for my company so i need an urgent help

    ReplyDelete

Be nice. That's all.