PDNSD mini-HOWTO
Sunil Thomas Thonikuzhiyil
v0.7, 11 September 2002.
How to use PDNSD to speed up your web browsing ?
______________________________________________________________________
Table of Contents
1. Where to find this document ?
2. About Pdnsd.
3. Installation.
4. Tweaking the configuration files.
5. Sample configuration files.
6. FAQs.
7. Credits.
______________________________________________________________________
1. Where to find this document ?
http://geocities.com/sunil_tt/pdnsd.txt
2. About Pdnsd.
Pdnsd is a caching DNS proxy server. Unlike BIND, it saves the RAM
cache to a file and the same is read up by Pdnsd for the next
Boot-up session. BIND when acting as a caching nameserver on your
local Dial-Up machine stores/caches the name to number translation
data onto your RAM. This is not written back to the hard-disk upon
a Power-down because it was not intended for a user/site who/which
is not always connected to the Internet. Laptop users' are greatly
benefitted by this nameserver utility.
On the other hand, Pdnsd can be configured to speed up Internet
browsing on a Dial-Up connection. How is this achieved ? Since DNS
resolution is referenced from the cached file, time is not wasted on
the name to number lookup. This in turn speeds up the name to
number translation, which actually accelerates your surfing.
Pdnsd is distributed under the GNU GPL and is available for download
at :
http://home.t-online.de/home/Moestl/
Redhat RPMS are got from :
http://home.t-online.de/home/Moestl/
Debian DEB packages are available at :
http://mirrors.kernel.org/debian/pool/main/p/pdnsd/
It is also apt-able. Do insert the following line in
/etc/apt/sources.list
deb http://http.us.debian.org/debian woody main
3. Installation.
Download pdnsd-.tar.gz from the above source.
Decompress and untar using:
tar zxvf pdnsd-.tar.gz
Change directory to pdnsd- and type
$ ./configure
Configure script accepts a number of parameters, see manual.txt file
supplied with the PDNSD source. Command line parameters --prefix and
--with-distribution are interesting.
$ ./configure --help will list all options
I am assuming that you have not specified any command line options.
Makefile generated by the auto-configure script will have the
following defaults:
default installation directory for Pdnsd is /usr/local (can be
changed with --prefix option to configure)
default location of the PDNSD cache is /var/cache/pdnsd
Pdnsd configuration file `pdnsd.conf' would be found in /etc
Now type:
$ make
This will compile pdnsd. I did not face any problem compiling it on
both Debian 2.2 and Redhat 6.1. Next su to root, as installation
requires root privileges.
Then type:
# make install
This step will do the following (quoted from pdnsd manual.txt):
1. Copies pdnsd to $(prefix)/sbin/
2. Copies pdnsd-ctl to $(prefix)/sbin/
3. Copies docs/pdnsd.conf (a sample configuration) to /etc/
(and backs up /etc/pdnsd.conf to /etc/pdnsd.conf.old).
If you have an /etc/pdnsd.conf.old you do not want to be
overwritten, save it to another place/name before doing 'make
install'
4. Creates your cache directory if it is not there. After
installation, you should check the file permissions and edit
/etc/pdnsd.conf to fit your needs . If you use the run_as
option, please make sure that your cache directory is owned by
the user you specified with this option! Please note that the
permission issue has been fixed as of the later releases.
Now /usr/local/sbin will contain two binaries pdnsd and pdnsd-ctl.
'pdnsd' is the proxy DNS daemon and 'pdnsd-ctl' is a program to
control the cache.
The cache is located at /var/cache/pdnsd/pdnsd.cache.The cache file
size will be 4 initially and will grow as and when you browse. This
aspect of the /etc/pdnsd.conf viz. 'perm_cache=;'. By default
it is set as 512(KB). Increase it according to your judgment and a
safe value would be 2048(KB) for a machine having 64MB RAM.
The cache file size will be 4 initially and will grow as and when
you browse Cache growth will be observed only after a reboot or
after restart of the Pdnsd daemon.
Pdnsd must be started up each time you boot the system . For this,
you have to install the start up scripts. The rc folder of the
source distribution contains startup scripts for Redhat, SuSE and
Debian. I have not tested the SuSE scripts.
Do the following depending upon your distribution.
a) Debian.
Copy pdnsd-/src/rc/Debian/pdnsd to /etc/init.d and type
update-rc.d. Stop the BIND server daemon if you have it installed
on your system. Edit /etc/resolv.conf and add the following:
nameserver 127.0.0.1
Comment out entries for all other name servers. Start pdnsd by
typing /etc/init.d/pdnsd start. Test pdnsd by typing nslookup.
On my system it displays:
Default Server: debian
Address: 127.0.0.1
>
Stop pdnsd by typing /etc/init.d/pdnsd stop.
Fire up your editor and add a line like this to the end of your
/etc/hosts file:
127.0.0.2 testhost
Save the file and start pdnsd once again. Type nslookup. Inside
nslookup type 'testhost'.
> testhost
Server: debian
Address: 127.0.0.1
Non-authoritative answer:
Name: testhost
Address: 127.0.0.2
If this answer is obtained it shows that your pdnsd is working.
(remember to remove the last line from /etc/hosts)
b) Redhat.
Copy pdnsd-/src/rc/Redhat/pdnsd to /etc/rc.d/init.d. Stop
Bind if you have it installed on your system. Edit
/etc/resolv.conf and add the following:
nameserver 127.0.0.1
Comment out entries for all other name servers. Start pdnsd by
typing /etc/rc.d/init.d/pdnsd start. Test pdnsd by typing
nslookup. On my system it displays:
Default Server: debian
Address: 127.0.0.1
>
Stop pdnsd by typing /etc/rc.d/init.d/pdnsd stop.
Fire up your editor and add a line like this to the end of your
/etc/hosts file:
127.0.0.2 testhost
Save the file and again start pdnsd. Type nslookup. Inside
nslookup type 'testhost'.
> testhost
Server: debian
Address: 127.0.0.1
Non-authoritative answer:
Name: testhost
Address: 127.0.0.2
If this answer is obtained it shows that your pdnsd is working.
(remember to remove the last line from /etc/hosts)
Now edit /etc/pdnsd.conf. Go to the servers section and modify it.
My pdnsd.conf looks like this:
global {
perm_cache=2048;
cache_dir="/var/cache/pdnsd";
max_ttl=604800;
# run_as="nobody";
paranoid=off;
server_port=53;
server_ip="127.0.0.1";
}
server {
ip="202.54.6.35"; /* My ISP DNS server. Fill in yours */
timeout=60;
interval=900;
uptest=none;
ping_timeout=500;
purge_cache=off;
caching=on;
}
server {
ip="202.54.1.30"; /* My ISP DNS server. Fill in yours */
timeout=60;
interval=900;
uptest=none;
ping_timeout=500;
purge_cache=off;
caching=on;
}
source {
ttl=86400;
owner="localhost.";
serve_aliases=on;
file="/etc/hosts;
}
/*
rr {
ttl=86400;
owner="localhost.";
name="localhost.";
a="127.0.0.1";
soa="localhost.","root.localhost.",42,86400,900,86400,86400;
}
rr {
ttl=86400;
owner="localhost.";
name="1.0.0.127.in-addr.arpa.";
ptr="localhost.";
soa="localhost.","root.localhost.",42,86400,900,86400,86400;
} */
This is a sample working configuration (DNS servers are of VSNL).
Start Pdnsd once more and connect to the Internet. Type nslookup and
do a query for say, yahoo.com. The server will respond, something
like this:
> yahoo.com
Server: debian
Address: 127.0.0.1
Non-authoritative answer:
Name: yahoo.com
Addresses: 204.71.200.245
Stop Pdnsd and disconnect from the Internet. Start Pdnsd again and
query for yahoo.com through nslookup. If you are getting the same
answer as above, fine, have a coffee and relax ! Else if not, there
is something wrong and ....??
4. Tweaking the configuration files.
If you are using Bind as your primary nameserver, one can very well
make Pdnsd the secondary one. But here you have a Catch-22
situation, On which local IP and port would you make the pdnsd
daemon process listen ? Look at ragOO's pdnsd.conf file and
named.conf file:
[pdnsd.conf]
global {
perm_cache=2048;
cache_dir="/var/cache/pdnsd";
max_ttl=604800;
run_as="pdnsd";
paranoid=off;
server_port=53
server_ip="127.0.0.3";
}
[named.conf--relevant section only]
options {
directory "/var/cache/bind";
forward first;
forwarders {127.0.0.3;202.54.6.1;202.54.1.30};
};
ragOO's GNU/Linux machine has local (lo) IP addresses from 127.0.0.1
to 8. This is the same in all GNU/Linux systems and one has the
option to specify 127.0.0.3 to be the alternate local server. Pdnsd
listens on Port 53 of lo device IP 127.0.0.3. In short, BIND would
be listening on port 53 of IP 127.0.0.1 and PDNSD on port 53 of IP
127.0.0.3.
Pdnsd will start caching only iff the first line of the namserver
section inside your /etc/resov.conf points to 127.0.0.3, ie. the
file /var/cache/pdnsd/pdnsd.cache will be seen growing.
Note that 127.0.0.3 can also be made the the first forwarder in
named.conf. This is not required as such if you have an entry in
/etc/resov.conf which points to the Local Pdnsd server.
5. Sample configuration file.
Will appear here shortly
6. FAQs.
The following question and answer is from a correspondence I had
with Thomas Moestl, the author of Pdnsd.
Q. I had a problem with your default installation. The cache was not
growing. It was stuck at 4 bytes. I changed ownership to 'nobody'
and it started growing. Probably a problem with my
configuration. Will you please let me know the correct dir/file
permissions/ownership for /var/cache/pdnsd and /var/cache/pdnsd/
pdnsd.cache ?
A. The best thing is to give the user who runs pdnsd write
permissions to the cache directory (and of course to the cache
file):
chown /var/cache/pdnsd
chmod 0700 /var/cache/pdnsd
chown /var/cache/pdnsd.cache
chmod 0600 /var/cache/pdnsd/pdnsd.cache
Where the permissions can of course be more liberal, if you
want. The ones given are the minimum required permissions. The
default permissions "make install" sets on the files are also
OK. The only important thing is to chown the file. Normally,
"make install" should also chowns the cache file (maybe a bug?
If this does not for you, please drop me a mail).
7. Credits.
Thanks to the author of this nifty utility, Thomas Moestl for
clarifying certain points and doubts. He made me a better user of
PDNSD :)
Thanks to Manoj Victor Mathew and Raghavendra Bhat
for mentioning about 'pdnsd' during one of the
ILUG-Cochin meets. ragOO edited and modified the draft heavily and
encouraged me to keep on modifying it. Last but not the least, to
all users of this elegant program who may have found this little
HOWTO useful. Enjoy....