Building a DHCP Server

coming soon...

Building a DNS Server

Types of Servers
Zones
Delegating Domains
Resource Records
Namespace
Authoratative Vs Non-authoritative Responses
Name Resolution
name resolution picture
From Verisign http://www.verisign.com/tl/nds.html

Recursive and Iterative Queries

Recursive: when resolver queries its name server and that name server follows the referrals and retrieves the answer for the client.
Iterative: The resolution process that the name server follows to retrieve the information for the client is iterative.

Forward and Reverse Queries
. -> us -> ca -> cc -> miracosta -> www
. -> arpa -> in-addr -> 10 -> 250 -> 15 -> 9
Getting Started

1. Decide on the name(s) of your namespace
2. Register your name with a registrar on the Internet
3. Contact your ISP regarding your new domain. Provide the information they require to support your domain.

Configuring Your Zone

Begin with the bind configuration file: /etc/named.conf options {
        ; The options are for global settings
        ; this is the location of your zone data files
        directory "/var/named";
       
        ; replace a.b.c.d with your external name server's IP
        ; perhaps this is your ISP's name server
        ; this is the name server to which unresolvable requests are sent
        forwarders { a.b.c.d; d.e.f.g; };

        ; If you have a slave server configured, uncomment this line
        ; allow-transfer { 192.168.1.1; localhost; };
        allow-query { 192.168.1.0/24; localhost; };
        allow-recursion { 192.168.1.0/24; localhost; };
};


; ACLs provide a simple way to referr to multiple hosts
; The following ACLs are for dynamic updates


acl "dhcp-clients" {

        192.168.1.0/24;
};

acl "dhcp-servers" {
        192.168.1.20;
};

acl "domain-controllers" {
        192.168.1.230;
};

zone "." in {
        type hint;
        file "root.hints";
};

# reverse zone for localhost
zone "0.0.127.in-addr.arpa" IN {
        type master;
        file "zone/db.0.0.127.in-addr.arpa";
};

zone "home-example.com" {
        type master;
        file "zone/db.home-example.com";
        ; uncomment if you want to allow dynamic updates to your database
        ; allow-update { "domain-controllers";"dhcp-servers"; };

};

zone "1.168.192.in-addr.arpa" {
        type master;
        file "zone/db.192.168.1";
        ; uncomment if you want to allow dynamic updates to your database
        ; allow-update { "domain-controllers";"dhcp-servers"; };

};


Now configure you forward and reverse zone files

The db.home-example.com file:

$TTL 3h
@   IN SOA  ns.home-example.com. nsadmin.ns.home-example.com. (
                       1       ; serial
                       3h      ; refresh (3 hours)
                       1h      ; retry (1 hour)
                       1w      ; expire (1 week)
                       1h      ; minimum (1 hour) negative caching TTL
                        )
; Now for the name server(s)
                      IN    NS   ns.home-example.com.

; Next the mail server(s)
; If you have more than one, associate a different number
; Lower numbers mean higher preferrence
                      IN    MX   10 mail.home-example.com.

; The addresses of your hosts beginning with the localhost
localhost             IN    A    127.0.0.1
ns                    IN    A    192.168.1.222
colima                IN    A    192.168.1.114
pavones               IN    A    192.168.1.115
michoacan             IN    A    192.168.1.116
oaxaca                IN    A    192.168.1.117

; Aliases
www                   IN    CNAME   home-nt4dt.com.
mail                  IN    CNAME   ns

The db.192.168.1 file:

$TTL 3h  ; 3 hours
@ IN SOA ns.home-example.com. nsadmin.ns.home-example.com. (
                      1       ; serial
                      3h      ; refresh (3 hours)
                      1h      ; retry (1 hour)
                      1w      ; expire (1 week)
                      1h      ; minimum (1 hour) negative caching TTL
                      )

; name server(s)

            IN    NS  ns.home-example.com.

; addresses of hosts
$TTL 1d      ; 1 day

222                  IN   PTR     ns.home-example.com.
116                  IN   PTR     michoacan.home-example.com.
114                  IN   PTR     colima.home-example.com.
115                  IN   PTR     pavones.home-example.com.
117                  IN   PTR     oaxaca.home-example.com.


The db.0.0.127.in-addr.arpa file:

$TTL 3h
@ IN SOA ns.home-example.com. nsadmin.ns.home-example.com. (
                     1      ; Serial
                     3h     ; Refresh
                     1h     ; Retry
                     1w     ; Expire
                     1h     ; Minimum TTL
                     )
 
                    IN   NS      ns.home-example.com.
1                   IN   PTR     localhost.


Start the Service and Test Your Configuration

# cat /etc/resolv.conf
search home-example.com
nameserver 192.168.1.222

# /etc/init.d/named start
  1. test local lookups
# nslookup ns
  1. test reverse lookups
# nslookup 192.168.1.222
  1. test root servers (if your domain is publically registered)
# nslookup ns.home-example.com.

Problems?

# grep daemon /etc/syslog.conf
daemon.*                           /var/log/named
# tail -f /var/log/named
# /etc/init.d/named stop
# /etc/init.d/named start


more later...