Sometimes, when you realize that you could have improved the system with so little effort, we blush. This is what happened to me when I realized that most of the neworking delays could have been avoided with this tiny but wity utility. I knew that having a local caching DNS or the like is the answer but I did not want to use a full fletched DNS server. I found pdnsd – a small proxy DNS server with permanent caching. Perfect!

In a nutshel, pdnsd is a small utility that caches DNS translations locally on the HD, hence next time the server queries the address the response time is likely to be minimal. Usually, the server has to query your ISP’s DNS or whatever DNS server you specified in the /etc/resolve.conf file. In a high performing web servers you are constantly competing with other packets on the network or your network resources. This is a great advantage. By installing pdnsd you achieve the following:
- Decrease the average DNS response time sharply!
- Increase your server performance, especially if this server needs to communicate externally a lot like an eCommerce server which constantly needs to communicate with shipping and credit card servers.
- Save on bandwidth.
Here is how you go about setting up pdnsd on a CentOS server:
1. Download the latest stable rpm:
go to pdnsd download page and look for your relevant rpm. For CentOS 5.2 64bit I got the latest version as of yesterday:
wget http://www.phys.uu.nl/~rombouts/pdnsd/releases/pdnsd-1.2.7-par_sl5.x86_64.rpm
2. Install the rpm:
rpm -i pdnsd-1.2.7-par_sl5.x86_64.rpm
3. Configure pdnsd to use your current DNS servers:
vi /etc/pdnsd.conf
Paste the following, of-course you should use your DNS servers instead:
server {
label="opendns";
ip = 208.67.222.222,208.67.220.220;
}
4. Start pdnsd and test that it is actually working
service pdnsd start
dig @127.0.0.1 yahoo.com
If you get the IP, it is working. Notice the response time, if you try again you will see a sharp decrease in response time. My servers’ second response time is almost always between 1-0 ms.
5. Set pdnsd to start automatically on boot
vi /etc/default/pdnsd
Enter the following and save:
START_DAEMON=yes
Also make sure the daemon is set to auto start on boot. I use ‘ntsysv’, you can use chkconfig or whatever you are used to.
6. Set your server to use the pdnsd instead of your DNS servers
vi /etc/resolv.conf
Make sure that the first nameserver line is ‘127.0.0.1′. Should look like this:
nameserver 127.0.0.1
7. Restart your network service:
service network restart
How do you know that it is working? try to use any script that needs to go outside to the network, like ‘yum update’. In most cases, you will notice that the second time is much faster. Enjoy!
Ron Peled LAMP: Linux Apache MySQL PHP, Performance Optimization, Web Application Hosting, Web Development CentOS, DNS caching, DNS proxy, pdnsd, Performance Optimization