|
|
Pushing the Limits of Home Electronics |
| home | linux | audio | about us | |
Lightweight Caching Nameserver1. OverviewIf you have a few computers at home and would like to be able to address them by name rather than IP address, you generally have two options:
I'm sure you'll agree that the second option sounds like the more maintainable option. Plus, you'll get a little performance boost by caching frequently accessed internet addresses on your local network. The following sections will show you how to install and configure a simple caching nameserver. 2. Server SetupNameservers are generally some pretty heavy-weight applications, and most of them are overkill for a small home network. The one I like to use is called pdnsd. 2.1. InstallationYou can download pdnsd from http://home.t-online.de/home/Moestl/index.html. Both the source and an RedHat-compatible RPM are available. To install the RPM, you would type rpm -Uvh pdnsd-1.1.6-1.i386.redhat.rpm Building the source is not much harder, if you choose that route. ./configure make make check make install # as root If you installed from the source, you'll have to copy the src/rc/RedHat/pdnsd file to /etc/rc.d/init.d/pdnsd. You should run control-panel as root and make sure that the pdnsd service is started and stopped in level 3 and 5. A number of 78 for both start and stop should work fine. 2.2. ConfigurationIf your installation succeeded, you should have a configuration file called pdnsd.conf in /etc/. If not, you can check for pdnsd.conf.sample or just copy the sample configuration below. There are lots of options discussed on the pdnsd web site, but a bare bones setup that should work for most people is shown below.
global {
perm_cache=512;
cache_dir="/var/cache/pdnsd";
max_ttl=604800;
run_as="nobody";
paranoid=on;
}
server {
ip="192.168.1.1";
timeout=30;
interval=30;
uptest=ping;
ping_timeout=50;
purge_cache=off;
}
server {
ip="xxx.xxx.xxx.xxx"; # Your ISPs first nameserver
timeout=30;
interval=30;
uptest=ping;
ping_timeout=50;
purge_cache=off;
}
server {
ip="xxx.xxx.xxx.xxx"; # Your ISPs second nameserver
timeout=30;
interval=30;
uptest=ping;
ping_timeout=50;
purge_cache=off;
}
source {
ttl=86400;
owner="localhost.";
serve_aliases=on;
file="/etc/hosts";
}
You should replace 192.168.1.1 with the IP address of the machine that pdnsd is running on, and replace xxx.xxx.xxx.xxx in the second and third "server" sections with the nameservers of your ISP. These are generally found in your /etc/resolv.conf. Now that you have a local nameserver set up, you can replace the nameserver directives in /etc/resolv.conf with the new nameserver machine. Since the nameserver is running on your local host, your /etc/resolv.conf should look something like this. nameserver 127.0.0.1 The last thing you need to do is put all of the IP addresses and domain names for your internal network in /etc/hosts. As seen in the "source" section of the configuration file above, this file is read by pdnsd to resolve internal network addresses. The hosts file has the following format. xxx.xxx.xxx.xxx hostname.domain.com hostname The first field is the IP address of the host. The second field is the fully qualified hostname. And, the third field is an alias or shortcut name for the host. 3. ConclusionBy setting up a caching nameserver on your home network, you can eliminate the headache of modifying the hosts file on each computer, and get a little network performance boost as well. Considering that the time and effort is quite minimal, this project gives you a lot of bang for the buck. |