Sunday, October 19, 2008

An obsessive compulsive guide to faster Internet access - Part 1 - DNS

When we hop on the Internet to visit that super cool website or chat with someone a million miles away, DNS is probably the last thing we're thinking about.

DNS is a service which translates a server name (like ttfloss.blogspot.com) into an IP address (like 72.14.221.191). No-one's going to remember the IP address (ok, I might, I meant no-one normal) so DNS is necessary for just about everything on the Internet to connect transparently.

As with many vital services, when it works, it works well and you don't even know it's there (or care really). When it dies, you're frustrated to your wits end.

I currently have blink broadband with TSTT (see, there was something Trini in this) and while the speed is ok, I have no clue what they're doing with their DNS servers. It's rather frustrating having a 2Mb line and waiting 5+ seconds to resolve a server name to an IP address. Before you call me impatient (which I am with machines, but that's besides the point), sites nowadays have re-directions, embedded iframes to sub-sites and whole sub-domains used for caching and load balancing. Basically about 4 to 5 lookups on popular sites just to figure out what servers to ask data for. Even worse if you're on dial up. I shudder to think about it.

At work, I'm not the network administrator. It's a more difficult kettle of fish as local server lookup is fine, but try to surf. Yowza.

How do I satisfy my need to speed by these DNS servers driving in the slow lane? pdnsd and OpenDns.

Caveat: This configuration may not allow you to resolve local network server names.

pdnsd is a neat caching DNS server easily installable from the Ubuntu repos (I think you need universe enabled to install it).

OpenDns is not, as the name implies, an Open Source DNS server or service (which is too bad), but a free DNS service (good) which uses lots and lots of caching to get you really fast replies to DNS requests. They work on ad revenue and by default you see them (the ads) when you mis-type a server name and it can't find the IP. It's worth it to me and I don't have any issue sending my DNS requests halfway around the world if they come back faster than the one on the same island.

Step 1 - Install pdnsd (Say that 5 times fast!)

pdnsd is in the repos so if you enter the following in a terminal
sudo apt-get install pdnsd
That should do the trick.

Step 2 - Configure pdnsd to use OpenDNS (kinda important)

There are a couple configuration things that need to be done. Open the config file by typing the following in a command line.
gksudo gedit /etc/pdnsd.conf
Comment out the section that says server with label resolvconf so it looks like below.

/*
server {
label="resolvconf";
}
*/

Now we need to add a server entry for OpenDNS. Put the following in the config file.

server {
label=OpenDNS;
ip=208.67.222.222;
ip=208.67.220.220;
timeout=30;
interval=30;
uptest=ping;
ping_timeout=50;
purge_cache=off;
}

That basically says to use the OpenDNS DNS servers to do lookups that are not in the cache to populate the cache.

Save the file and then start / restart pdnsd. From a terminal type
sudo /etc/init.d/pdnsd restart
It's now all nice and configured.

Step 3 - Start using the pdnsd server (about time!)

Many of us get dynamic IPs from a dhcp server. To use the pdnsd DNS instead of the one suggested by the DNS server, execute the following commands. (This is for Ubuntu based Linuxes).
gksudo gedit /etc/dhcp3/dhclient.conf
While editing the dhclient.conf add the following line and save the file.
prepend domain-name-servers 127.0.0.1;
You can restart the network (or reboot) for the changes to take effect.

Step 4 - I can't see anything on the local network! Fix it!

I haven't really figured this out. You can follow some OpenDNS steps. They didn't really work for me. I'm sure pdnsd can let me fix this, but I haven't figured it out as yet.

Right now I have a couple of entries in my /etc/hosts file for local servers I use at work and it's good enough for now.

Worst case scenario, remove the prepend line from the dhclient.conf and restart the network.

If I figure out how to fix this I'll post an update. In the meantime, enjoy (slightly) faster surfing. :).

No comments: