djbdns Guide - Setup your own nameserver

There are a number of reasons someone might want to run a local DNS server/cache. Maybe your ISP's DNS servers are wonky, maybe your on dialup and just wanna get things a bit faster, or maybe something completely different.

This guide will walk you through the process of setting up your very own local DNS server/cache for your network. This guide assumes you are using
Gentoo Linux, but 99.9% of the information is valid for any Linux distro.

Step One:

First we need to get xinetd up and running (since we intend to run this as a service for all the computers on our network).

emerge xinetd
/etc/init.d/xinetd start
rc-update add xinetd default

You will probably also want to change the default setting only_from = localhost to your local network in the file /etc/xinetd.conf.

At this point xinetd will be up and running and we are ready to setup
djbdns.

Step Two:

Next we will install djbdns as we would install most any other package.

emerge sys-apps/daemontools
emerge net-dns/djbdns

Debian users: apt-get install djbdns

*optionally: emerge app-doc/djbdns-man

After this step we will have all the software we need to get our DNS server/cache up and running.

Step Three:

We need to decide on what user accounts to have all this run as. You can set it to run as "nobody" or you can create two new user accounts to manage all this. If you want the user accounts do this:

useradd gdnscache
useradd gdnslog

Now we have all the user accounts we need to get this setup. Next we will have dnscache-conf setup our initial config for us.

dnscache-conf gdnscache gdnslog /etc/dnscache INTERFACE_ADDRESS

Make sure that "/etc/dnscache" does NOT exist right now, dnscache-conf will create it for you.
Secondly replace INTERFACE_ADDRESS with the IP address the service is meant to bind to.

Step Four:
Lastly, we need to get the service up and running and let others machines on the network access it.

First we need to get this added to svscan.

ln -s /etc/dnscache /service
sleep 5
svstat /service/dnscache

Now we need to grant permission to certain IP's and IP blocks.

touch /etc/dnscache/root/ip/10

This will allow any IP address in the 10.x.x.x range to access your dns server. You can put as many entries in this directory as you like. If you added:

touch /etc/dnscache/root/ip/192.168.x.x

You will be granting permission to all the 192.168.x.x IP addresses.

Well, congrats you now have yourself a local dns server/cache. Next we need to set your clients to utilize it!

Client Configuration

Linux (standard):
By default Linux looks in /etc/resolv.conf to get information about what nameservers to use. Simply put:

nameserver DNS_ADDRESS

Into your resolve.conf. Of course replace DNS_ADDRESS with the address of the new dns server. Be sure there are no other nameservers listed above this one. Use 127.0.0.1on the box you are running the DNS server on.

Linux (Gentoo):

The problem with the above method is by default if you use DHCP it will wipe those values out each time it gets a new lease. So lets setup Gentoo the "right way". First do what was outlined in the previous example. Then open /etc/conf.d/net and add:

dhcpcd_eth0="-R"

The -R option tells the DHCP daemon to not overwrite enteries in /etc/resolv.conf.

After this right click on "Local Area Network" and select "Properties". Select "Internet Protocol (TCP/IP)" and click "Properties". Select "Use the following DNS server addresses" and put the new server in the "Preferred DNS server" box. Click OK and be done!

Xbox
I will let pictures tell most of this story.

If you are immediatly placed into Xbox Live from the Dashboard select "Main Menu" from this screen.

Select "Settings" from the Main Menu.

Now select "Network Settings".

And now select "DNS Servers".

Set the configuration to "Manual" and then select "Primary DNS".

Use the keypad to enter the IP address of your new DNS server.

Finally select "Connect" from the Network Settings menu to test your new settings. You should see the following:

Well that is it. Enjoy your new DNS server. Look in "/etc/dnscache/log/main/current" to see what is happening.