A common complaint on the Ubuntu forums (and many other Linux sites, it seems) is the slow DNS look-up performance, especially compared with the same hardware running Windows.
One way of improving performance is to provide DNS caching on the local machine, so that repeated look-ups are quicker -- a local request rather than a trip out to the Internet and back. Although some client programs do this for themselves (notably web browsers), many don't (notably mail clients, it seems to me).
This being Linux, there are many ways to achieve local DNS caching, of course, ranging from the simple to the complicated. I have looked at several methods and this is the one that suits my needs. I'm running a desktop installation on a small home network and the machine is rebooted daily. This means that I need a solution that remembers its cache after a reboot -- I don't want to have to cache everything every morning. This requirement for persistence let me to pdnsd (p for persistent ), but it suffers from a remarkable lack of documentation for the novice. Eventually, I found this article on the Debian Administration site, which got me going in the right direction, but there are a couple of things to be clarified.
This is the procedure as I did it.
Note that these details are for Dapper with Gnome and without resolvconf installed. I don't think anything will break if these changes are made to a different setup, but it may not work. I haven't tried it.
Install pdnsd -- either by Synaptic or apt:
Now some editing of the pdnsd.conf file. Start gedit as root user in a terminal (or Alt-F2):
sudo apt-get install pdnsd
Substitute your preferred editor, as required.
gksudo gedit /etc/pdnsd.conf
Save a back-up of the original -- e.g., Save As -> pdnsd.conf.orig
Now, find the part of pdnsd.conf that contains the DNS server to be used:
and change it to read:
1. It is vital to remove the '/*' and '*/'. These are comment markers and nothing will work if they are left in! Not obvious if you're not familiar with coding conventions (that's me!).
2. It is vital to include the semi-colon at the end of each line.
3. The 'label=' entry is optional, but may be useful for future diagnostics.
4. I have used the OpenDNS IP addresses. These will work, but you may prefer to use your ISP's or other DNS servers.
Summary: I removed the comment signs and added a label and the two IP addresses. Other entries are unchanged.
Next, comment out the part referring to resolvconf by adding /* and */ so that it looks like this:
Save the file as /etc/pdnsd.conf but don't close the editor window yet.
# if you installed resolvconf, and status_ctl=on
Most of us, I expect, use DHCP to set IP addresses on boot, so we need to make sure that our settings survive a reboot. Amongst other things, DHCP tells the system where to find DNS servers, so open /etc/dhcp3/dhclient.conf in the editor.
Remove the comment mark (#) from the beginning of this line:
and save the file.
#prepend domain-name-servers 127.0.0.1;
In order to avoid having to reboot immediately, edit /etc/resolv.conf and add this line at the top of the file:
(This is what the changes to dhclient.conf will do automatically at boot.)
The system will now look to the local cached DNS information rather than going directly to the Internet.
Restart pdnsd to make our changes active:
If you want to test this arrangement and compare results, that is explained in the reference article, but I found that it was pretty obvious just by browsing to websites.
sudo /etc/init.d/pdnsd restart
The first time a site is visited, there will be a delay while pdnsd finds the IP address from the external DNS servers, but subsequently it will just pull it from its cache -- like lightning!
Steve Kemp's article on Debian Administration -- thank you very much.
pdnsd homepage: Comprehensive documentation is here, but it may not be very accessible to us novices.
Also mentioned in this thread in connection with Internet Connection Sharing.
Remove the pdnsd package with Synaptic or apt:
Restore original backup file for /etc/dhcp3/dhclient.conf (or add the # to the beginning of the 'prepend' line).
sudo apt-get remove pdnsd
Restore original backup file for /etc/resolv.conf (or remove the 'nameserver 127.0.0.1' line).
I am not an expert. I'll answer questions if I can, but mostly I'd have to research the answers first. Or you could do the research and tell the rest of us.
Ubuntu 6.06 Desktop i386, up to date today, Friday, 5 January 2007.
Please form an orderly queue with corrections.