I was sent a web link today that contained a great article about how to speed up web browsing by locally caching DNS name resolution results using dnsmasq. That article is great and it is here: Local DNS Cache for Faster Browsing. I like it because it is equally simple to do and works, but the results (of DNS lookups) are not saved after your PC or laptop “session” is finished.
To clarify, in my opinion, one of the drawbacks (someone correct me if I’m wrong), seems to be that the cache is lost after the laptop or PC is turned off.
To resolve that issue, I prefer to use pdnsd.
As a side note: if you’re looking for a fast, reliable DNS server, I’ve been using OpenDNS for 2 years and the service has been reliable (and arguably provides faster responses than the DNS servers from my ISP). I will be using their DNS server IP’s to configure pdnsd - But you can use any DNS server IP’s you want.
To install pdnsd simply use apt-get by issuing the following command in an Ubuntu Linux terminal window:
sudo apt-get install pdnsd resolvconf

As I mentioned, this will cache the results of DNS lookups to your hard drive and therefore improve your web surfing speed. As a side not, don’t omit the “resolveconf” part (above). If you omit it, then you may run into problems when different applications/programs are trying to access (or change) the configuration file (found at /etc/resolv.conf).
After the install is complete (it should be fast), edit that configuration file by issuing this terminal command:
sudo gedit /etc/pdnsd.conf
One of the significant change I made is:
label = “OpenDNS”;
ip=208.67.222.222,208.67.220.220;To compare, here is what my complete edited pdnsd.conf file contains:
global {
perm_cache=512;
cache_dir=”/var/cache/pdnsd”;
max_ttl=604800;
run_as=”pdnsd”;
paranoid=on;
# next setting allows ppp/ip-up update the name servers — ABa / 20040213
status_ctl=on;
server_port=53;
server_ip=”127.0.0.1″;
}#Edit these to be your own servers if wished:
server {
label = “OpenDNS”;
ip=208.67.222.222,208.67.220.220;
proxy_only=on;
timeout=10;
}# if you installed resolvconf, and status_ctl=on
server {
label=”resolvconf”;
}source {
ttl=86400;
owner=”localhost.”;
# serve_aliases=on;
file=”/etc/hosts”;
After saving your changes, you’ll need to restart the server by issuing this terminal command:
sudo /etc/init.d/pdnsd restart
Then of course, test that everything is working. I used the command:
digg ubuntu.com
And received resolution in 74ms as below

Then (as I knew this should be cached), I re-issued the above command. In my case name resolution using the cached results was 1ms - Wow!

A great way to help speed up your web surfing.
Not bad for 10 minutes work on a saturday afternoon!



There are 8 comment(s) added so far...
Very nice. This seems to be yet another reason to hop over to Ubuntu. I’ve also been using OpenDNS for about two years and haven’t looked back.
What’s the disk cost of DNS caching? I would think that after several weeks or months of power-surfing that the cached DNS files would become so large that there would be no noticable gain to it.
@Jason
That’s a great question! Thanks.
I do know that you can control the amount of space used…
There is a configuration switch like this:
<strong><em>perm_cache=(number|off);</em></strong>
You can use it to switch the disk cache off (<em>perm_cache=off</em>) or supply a maximum cache size in kB. If the disk cache is switched off, 8 bytes will still be written to disk. The memory cache is always 10kB larger than the file cache. This value is 2048 (2 MB) by default.
So for example you can edit the configuration file by:
sudo gedit /etc/pdnsd.conf
and edit the perm_cache parameter to your needs.
Mine looks like this:
<blockquote>
global {
perm_cache=512;
cache_dir=”/var/cache/pdnsd”;
max_ttl=604800;
.
.
.</blockquote>
If you really want to be the resident guru <smiling here> I found all the settings here: http://www.phys.uu.nl/~rombouts/pdnsd/doc.html
There are such a vast array of setting, it’s pretty good too that they are properly documented.
(One of the reasons why I became an Ubuntu user was because of the community support!)
I hope this reply helps answer the question.
dnsmasq - A lightweight DHCP and caching DNS server
This is another solution that works for me.
For anyone interested in this too, here is the link for them: http://www.thekelleys.org.uk/dnsmasq/doc.html
I agree with Bolangi, I tried that and it worked nice! The only difference is that there is no disk caching.
;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Fri Apr 4 00:20:33 2008
;; MSG SIZE rcvd: 156
I am using bind for this.
@tallman - That’s fast!
Does this still apply on 7.10 and 8.04?
@Vadim P. - I did this on 7.10 as well and it caused no problems. I’ve not tried on 8.04, yet. I’m waiting for the stable release to come out (I think it’s about 9 or 10 days before release).