Often, I find, You hit a website and you see “Looking up http://www.zzzzz.com” in status bar. This becomes intensified if you are running a P2P software like torrents.
Often people enable host name resolution in torrents. With hundreds of connections and name resolutions, I often feel the rates of “Looking up … ” continuously increases. These are most definitely DNS name resolution delays. Running a quick sniff for a un-responding website suggests a name resolution delay.
Ok so, I realized Airtel’s DNS servers were somehow exhausted. [May be an implication of upgraded speeds ;)]
Local DNS serving/caching can make for a much more responsive browser and lesser timeouts.
So I searched around to find a local DNS cache implementation. Some I found were – dnsmasq, nscd, treewalk dns for windows and my favourite, pdnsd.
Now dnsmasq can do a lot more stuff, But I liked pdnsd more as it could cache the name resolutions on to disk for a more permanent effect. Provides a lot more meaningful and usable options. And above all its very easy to configure.
So here’s how to proceed.
Grab a terminal and
sudo apt-get install pdnsd.
Lets edit /etc/pdnsd.conf to set up some meaning full options.
Here’s how my file looks like now:
max_ttl=604800; # 1 week
# next setting allows ppp/ip-up update the name servers -- ABa / 20040213
Have a look at man pdnsd.conf to find what everything means. The important settings are:
- max_ttl=604800; # 1 week : TTL after which the entry expires. I kept 1 week. You can keep sthing like 2h20m. Check out man for more formats.
- run_as=”pdnsd”; : User context. If you don’t wanna mess around, you can just ensure proper read write permissions to /var/cache/pdnsd/pdnsd.cache
- server_ip=”127.0.0.1″; : You can keep anything 127.0.0.X (X is any number < 254)
- ip=”10.1.1.1″; This is ip of dns server you are currently using. I have given my router address which uses airtel servers to provide me resolutions.
Now edit /etc/resolv.conf to add local DNS server. So fireup a sudo gedit /etc/resolv.conf. Add an entry at the top as :
nameserver 127.0.0.1. (This could be 127.0.0.X if you used sthing else previously). You can even get rid of other entries if you really want. The first entry becomes your primary dns.
Now lets make sure that the entry remains there in case a new DHCP lease is obtained.
Now edit /etc/dhcp3/dhclient.conf to add a line
prepend domain-name-servers 127.0.0.1; such that the starting segment looks like :
#supersede domain-name "fugue.com home.vix.com";
prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, host-name,
Instead of editing above two files (resolv.conf and dhclient.conf) you can also install a tool resolvconf. In that case you might have to enable it in /etc/pdnsd.conf.
That’s it. We are done. Restart the service for new settings to take effect.
sudo /etc/init.d/pdnsd restart.
Running a quick “dig ca.com” gave resolution time of 330ms. Running again gave 1ms. Oh by the way ‘dig’ is a nice small dns lookup utility.
Since we have touched this topic. I would also recommend using opendns servers as name servers in pdnsd server list. The best advantage is they are better responsive dns servers. All you need is to setup some static opendns server ips as your name servers in server – ip area of pdnsd.conf file.
If your optionally register, and add your network, you can gather stats about your name resolution requests. They also support addition of dynamic ips by providing clients which can register your ip everytime. Moreover you can also integrate it with dynamic host services providers like dyndns.org
You can setup phishing filters, adult site blocking, domain blocking, typo corrections for your configured networks and keywords for domains. I truly like the concept. Its like you control which sites can get resolved for your internet connection.
Anyways for Windows folks –
TREEWALK DNS : Can be found at http://www.ntcanuck.com