Search This Blog

Thursday, 3 December 2009

Configuring linux DNS server for LAN.

This is a caching DNS server for internet and DNS server for my local network. If any DNS entry is not available in local cache, it will forward the the same request to ISP DNS server and cache the same locally for next time. This will speed up the NAME resolving process.

There are some multiple entry for same IP. This for apache virtual host propose (By using this it is possible to host multiple website in a single IP. Apache divert the page by looking in the name the the client queried for)

Step 1:

Installing  DNS server: 

yum install bind-9*

Step 2: Editing configuration Files

[root@latheefp named]# cat /etc/named.conf
acl mynet {; 127.0/8; }; 
options {
# listen-on port 53 {; }; #replace this line with below
listen-on port 53 {;;; }; # All the system in the and 192.168.15.x can acess this dns server.All three above are the IPs for this host.
listen-on-v6 port 53 { ::1; }; #This is the default dns port. 
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { mynet; };
recursion yes;
forwarders {; }; #IP of upstream ISP nameserver(s)
forward only; #relay completely on our upstream nameservers

channel simple_log {
file "/var/log/bind.log" versions 3 size 5m; #For any lookup, it make a log in this file
severity warning;
print-time yes;
print-severity yes;
print-category yes;
category default{

#This is my forward zone, all local IP and Host names are defied here
zone "riyadh.lan" IN {
type master;
file "/var/named/";

# Reverse Zone for riyadh.lan domain
zone "" IN {
type master;
file "/var/named/";
zone "." IN {
type hint;
file "";

include "/etc/named.rfc1912.zones";

Step 3: Making Forward lookup zone file
This is the forward lookup zone db. 

For adding/removing/modifying any system, just do a entry in the bottom these two files and restart yp.

[root@latheefp /]# cat /var/named/
riyadh.lan.      IN      SOA     ns.riyadh.lan. admin.riyadh.lan. (

                                                        3H ;refresh
                                                        15      ;retry
                                                        1w      ;expire
                                                        3h      ;negative ttl
                        IN      NS      ns.riyadh.lan.
                        IN      MX 10   mail.riyadh.lan.
ns                      IN     A
shimna                  IN     A
audit                   IN     A
phpmysql                IN     A
shimna                  IN     A
wimax                   IN     A    ;modem
wan             IN     A  ;modem
wifi            IN     A   ;wifimodem
mds                     IN     A     ;mds lap
tiger                   IN     A     ;tiger server
mail                    IN     A    ;tiger server
bitt                    IN     A ;webserver
ent                     IN     A ;webserver
film                    IN     A ;webserver
song                    IN     A ;webserver
;log                    IN     A ;webserver
webmin                  IN     A ;webserver
chimmu                  IN    A
webtiger                IN      A
linux           IN      A
ganglia         IN      A
iphone          IN      A
E65             IN      A
;shimna         IN      A
node1           IN      A
win7            IN      A

Step 4: Editing corresponding reverse lookup file.

[root@latheefp/]# cat /var/named/
@ IN SOA ns1.riyah.lan. admin.riyadh.lan. (

@                     IN    NS    ns.riyadh.lan.              IN    PTR   ns.riyadh.lan.               IN    PTR   shimna.riyadh.lan.               IN    PTR   audit.riyadh.lan.               IN    PTR   phpmysql.riyadh.lan.               IN    PTR   shimna.riyadh.lan.               IN    PTR   bitt.riyadh.lan.               IN    PTR   ent.riyadh.lan.               IN    PTR   webmin.riyadh.lan.              IN    PTR   mail.riyadh.lan.              IN    PTR   film.riyadh.lan.              IN    PTR   song.riyadh.lan.
;               IN    PTR   log.riyadh.lan.               IN    PTR   webtiger.riyadh.lan.               IN    PTR   chimmu.riyadh.lan.             IN    PTR   wifi.riyadh.lan.               IN    PTR   mds.riyadh.lan.               IN    PTR   tiger.riyadh.lan.              IN    PTR   wimax.riyadh.lan.            IN    PTR   wan.riyadh.lan.            IN    PTR   linux.riyadh.lan.            IN    PTR   ganglia.riyadh.lan.            IN    PTR   iphone.riyadh.lan.            IN    PTR   E65.riyadh.lan.
;            IN    PTR   shimna.riyadh.lan.            IN    PTR   node1.riyadh.lan.            IN    PTR   win7.riyadh.lan.

Step 5: Starting DNS server:

[root@latheefp/]# /etc/init.d/named start
Starting named:                                [  OK  ]

Named can be restarted using below command

[root@latheefp/]# /etc/init.d/named restart
Stopping named:
                                               [  OK  ]
Starting named:                    [  OK  ]

Now in any system in 192.168.1.x and 192.168.15.x  network can access this dns server for lookup.It can resolve all local hosts and other global hosts.

No comments:

Post a Comment