toplogo.png
up Home Computers Home Dns
From http://craig.backfire.ca/pages/computers/home-dns

I have a DNS server running at home, so that I do not need to memorize IP addresses. I can just type the names of the computers. DNS is great. This page shows a few cut and paste configs that can be used to get a DNS server rolling with almost no fuss. Very cool.

This config works for BIND version 9 under FreeBSD 5, and probably FreeBSD 6 too. I use 10.0.1.0/24 as my IP range for my LAN, and .home.lan as the domain for all of the computers. The DNS server is called ns1.home.lan. If you change these few things to match up how your LAN is setup, the text below can be pretty much copied and pasted.

First, FreeBSD must be configured to start named on boot. Append the line below into /etc/rc.conf:

named_enable="YES"

Setup the localhost domain:

cd /var/named/etc/namedb/
sh make-localhost

Here is my /var/named/etc/namedb/named.conf:


options {
        directory "/etc/namedb";
        pid-file    "/var/run/named/pid";
        dump-file   "/var/dump/named_dump.db";
        statistics-file "/var/stats/named.stats";
        forward first;
        named-xfer "/bin/named-xfer";
        forwarders {
            // These IPs are my ISP's DNS servers.
            24.226.10.193;
            24.226.1.93;
            24.226.10.194;
            24.226.1.94;
            // 24.153.22.67;
            // 24.153.23.66;
        };
        listen-on {
           // DNS server computer's
           // internal IP and localhost IP
           10.0.1.1;
          127.0.0.1;
        };
        version "Not Telling"; // Don't reveal BIND ver
        query-source address *
        port 53;
};

zone "." {
        type hint;
        file "named.root";
};

zone "0.0.127.IN-ADDR.ARPA" {
        type master;
        file "master/localhost.rev";
};

// My LAN and my Domain. Change these.
zone "1.0.10.in-addr.arpa" {
    type master;
    file "master/home.lan-rev";
};
zone "home.lan" {
    type master;
    file "master/home.lan-fwd";
};

Then, in /var/named/etc/namedb/master/:

home.lan-rev:

$TTL 86400
@ IN SOA @ root.localhost (
17 ; serial
28800 ; refresh
7200 ; retry
604800 ; expire
86400 ; ttk
)

@  IN NS  ns1.home.lan.
1  IN PTR shifter.home.lan.

5  IN PTR burnout.home.lan.

100 IN PTR laserprinter.home.lan.

201 IN PTR josh.home.lan.
202 IN PTR kyler.home.lan.
203 IN PTR mark.home.lan.
204 IN PTR matt.home.lan.
205 IN PTR sarah.home.lan.

255 IN PTR bcast1.home.lan.

home.lan-fwd:

$TTL 86400
@ IN SOA ns1.home.lan. shifter.home.lan. (
24 ; serial
28800 ; refresh
7200 ; retry
604800 ; expire
86400 ; ttk
)

@      IN NS ns1.home.lan.
@      IN A  10.0.1.1
@      IN MX 0 mail.home.lan.
ns1    IN A  10.0.1.1

localhost IN A 127.0.0.1
self      IN A 127.0.0.1

; Real Machines
burnout      IN A  10.0.1.5
shifter      IN A  10.0.1.1
redline      IN A  10.0.0.2
laserprinter IN A 10.0.1.100

; Aliases
gw      IN CNAME shifter
proxy   IN CNAME shifter
wpad    IN CNAME shifter
mail    IN CNAME burnout
webmail IN CNAME burnout
files   IN CNAME burnout

; People's Machines
craig   IN CNAME redline
josh    IN A 10.0.1.201
kyler   IN A 10.0.1.202
mark    IN A 10.0.1.203
matt    IN A 10.0.1.204
sarah   IN A 10.0.1.205

Then, the DNS server can be launched with the rndc start command.

The DNS server should have an /etc/resolv.conf file that looks like this:

search home.lan
nameserver 127.0.0.1

It should be noted that if the DNS server gets an IP from the ISP via DHCP, the dhclient program will always overwrite the /etc/resolv.conf file with it's own. To solve this, create a file called /etc/dhclient-enter-hooks, and make sure it is executable. Then, add the lines below to the file:

make_resolv_conf()
{
echo "Avoiding resolv.conf lameness"
}

Other FreeBSD or Linux machines can be taught to use the DNS server by creating a file called /etc/resolv.conf, and putting the lines below into it:

search home.lan
nameserver 10.0.1.1

That's it! Contact me if there are any problems.

Rate This Page

Mouse over the nuts to rate. ZERO NutsOne NutTwo NutsThree NutsFour NutsFive Nuts 

Page last modified on December 29, 2009 23:30:08. (ID=68)