Skip navigation

Tag Archives: dns

My tweet you just read says the long story short. In case you didn’t come across, Google made DNS a buzzing topic again with Google Public DNS. So I felt like trying a dns cache again. The logic is “If a better DNS server makes things better, DNS cache makes it even better.”

This is more of a note to self than a HOWTO. If your use case atches with mine, feel free to use this.

My use case: I use an HSDPA, mobile broadband connection on Ubuntu 9.04 Jaunty Jackalope.

Install pdnsd with,

$sudo apt-get install pdnsd

Now launch the text editor you hate and add following to /etc/pdnsd.conf

(By default all the parts are commented so just adding this was fine enough for me)


server {
ip=208.67.222.222 , 8.8.8.8;
timeout=5;
interval=30;
uptest=ping;
ping_timeout=50;
purge_cache=off;
}

global {
 perm_cache=5120;
 cache_dir="/var/cache/pdnsd";
 min_ttl=15m;       // Retain cached entries at least 15 minutes.
 max_ttl=1w;        // One week.
 timeout=10;        // Global timeout option (10 seconds).
}

I copied this piece from here and edited ;). Added the global field because defaults were not cool enough for me. And in ip field I’ve put respectively OpenDNS and Google DNS addresses. You can just add one address there. ‘man pdnsd.conf’ will teach you more about the content in the file.

Once you are done editing the configuration file restart pdnsd with

$sudo /etc/init.d/pdnsd restart

Now you should tell the network manager to look for pdnsd for it’s DNS needs.

Right click network manager icon and then follow Edit Connections > Mobile Broadband and choose to edit your preferred network connection.

In Editing <Your Network Connection> dialog box,
[1] Choose IPv4 Settings tab
[2] Choose Automatic Addresses (ppp) Only in Methods Dropdown box.
[3] Set DNS Servers field to 127.0.0.1 (which refers to pdnsd in our case)

And obviously, Apply Changes :P .

If everything went fine, you are now ready to enjoy DNS cache goodness with pdnsd.

You can check how good is it with dig command.

ex:
$dig yahoo.com

run this command twice and compare Query time field.

Note: If you followed all the steps but still it doesn’t work, try restarting pdnsd. If you get following error refer this page

/etc/resolv.conf must be a symlink

Update: Added the global settings for config file.

It’s over. The fight against the dynamic DNS is over for me now. It took me so long to figure this simple thing out. But I don’t worry, even the big bro Goog couldn’t come up with a satisfying straight answer for my problem. So I myself searched under the mattress & found the pea which took my good night sleep (I’m neither a princess nor prince ;) ).

Sometimes back I had to come up with a pretty shitty solution for a shitty problem. No I didn’t won’t to show how bad my thinking or coding is. But wanted to show how shitty is the service of my ISP. But however the right way to fix all those are here with me. And I’m gonna share it with you.

If you use wvdial to dial up (Ok, now only seven people at most will continue reading this) for your internet connection, and you hate the DNS servers come your way automagically, here’s what to do.

Open /etc/ppp/peers/wvdial with your favorite text editor & comment the line usepeerdns. I mean make it look like #usepeerdns. Now wvdial won’t ask pppd to fetch those crappy DNS addresses again.

So go and edit your /etc/resolv.conf file and add you favorite DNS servers there. Mine looks like following.

nameserver 127.0.0.1
nameserver 208.67.222.222
nameserver 208.67.220.220

Wonder why I use 127.0.0.1 there? That’s because I’m a happy user of dnsmasq (I recommend you to use it). I used this simple HOWTO to install it on Ubuntu. There should be other guides & HOWTOs which might match you (In case that one doesn’t fit). Just ask big bro Goog.

And other nameservers are of the nice free DNS service OpenDNS.