Setting up a DNS Server for your LAN Network

Fri, May 8, 2009

Linux

This tutorial will show you how to configure bind9 on debian to be a dns server for your LAN network.

  1. Install bind9 and some DNS utilities
    apt-get install bind9 dnsutils
  2. Set your systems hostname
    echo "server.home.local" > /etc/hostname 

    then edit /etc/hosts so it looks like this

    127.0.0.1       localhost.localdomain   localhost
    192.168.1.2    server.home.local        server
    # The following lines are desirable for IPv6 capable hosts
    ::1     ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts
  3. change you DNS servers by editing /etc/resolv.conf
    nano /etc/resolv.conf

    it should look something like this:

    search home.local
    nameserver 192.168.1.2
  4. Creating a Zone

  1. The zone files are the most important part of the BIND system. They hold all the information as to what hostname goes to an IP. to get started edit /etc/bind/named.conf.local
    nano /etc/bind/named.conf.local

    and then add the following:

    zone "home.local" {
            type master;
            file "home.local";
    };
    
    zone "1.168.192.in-addr.arpa" {
            type master;
            file "192.168.1";
    };
  2. Now we need to create the zone file in /var/cache/bind/home.local
    nano /var/cache/bind/home.local

    and add the following:

    $TTL 604800
    @ IN SOA server.home.local. sysadmin.home.local. (
                    2008080101      ;serial
                    04800           ;refresh
                    86400           ;retry
                    2419200         ;expire
                    604800          ;negative cache TTL
                    )
    @       IN      NS      server.home.local.
    @       IN      A       192.168.1.2
    @       IN      MX      10      server.home.local.
    server  IN      A       192.168.1.2
    www     IN      CNAME   server
    desktop	IN	A	192.168.1.3
    printer	IN	A	192.168.2.4
    laptop	IN	A	192.168.2.5
  3. Now we need to create the reverse DNS zone file to do so we need to create /var/cache/bind/192.168.1

    nano /var/cache/bind/192.168.1

    and add the following:

    $TTL 604800
    @ IN SOA server.home.local. sysadmin.home.local. (
                    2008080101      ;serial
                    604800          ;refresh
                    86400           ;retry
                    2419200         ;expire
                    604800          ;negative cache TTL
                    )
    @       IN      NS      server.home.local.
    @       IN      A       192.168.1.2
    2	IN	PTR	server.home.local.
    3	IN	PTR	desktop.home.local.
    4	IN	PTR	printer.home.local.
    5	IN	PTR	laptop.home.local.
  • We now need to set DNS servers to forward to so edit /etc/bind/named.conf.options
    nano /etc/bind/named.conf.options

    and add the following

    forwarders {
                    208.67.222.222; // your isps dns server
                    208.67.220.220; // your isps dns server
            };
  • Now we need to restart bind9 and test it
    /etc/init.d/bind9 restart

    dig home.local

    you should see the following

    ; < <>> DiG 9.3.4 < <>> home.local
    ;; global options:  printcmd
    ;; Got answer:
    ;; ->>HEADER< <- opcode: QUERY, status: NOERROR, id: 54950
    ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1
    
    ;; QUESTION SECTION:
    ;home.local.                    IN      A
    
    ;; ANSWER SECTION:
    home.local.             64800   IN      A       192.168.1.2
    
    ;; AUTHORITY SECTION:
    home.local.             64800   IN      NS      server.home.local.
    
    ;; ADDITIONAL SECTION:
    server.home.local.        64800   IN      A       192.168.1.2
    
    ;; Query time: 1 msec
    ;; SERVER: 192.168.1.2#53(192.168.1.2)
    ;; WHEN: Tue Aug  5 09:33:40 2008
    ;; MSG SIZE  rcvd: 79
  • Configure all computers in your network to use 192.168.1.2 as there dns server and you should be good to go
  • , , , , , ,

    This post was written by:

    Duffy - who has written 48 posts on Tuts4Tech.

    I am the owner of this website, please feel free to ask me any questions you have

    Contact the author

    One Response to “Setting up a DNS Server for your LAN Network”

    1. Irwin Sassano
      Irwin Sassano Says:

      Fed up with obtaining low amounts of useless visitors to your website? Well i wish to let you know about a fresh underground tactic that makes me personally $900 on a daily basis on 100% AUTOPILOT. I really could be here all day and going into detail but why dont you just check their website out? There is really a great video that explains everything. So if your serious about producing effortless cash this is the site for you. Auto Traffic Avalanche

      Reply


    Leave a Reply