
I’m always looking for ways to improve on my LAN, especially when it’s free. A friend suggested DNS caching to speed up browsing. I gave it a shot and was impressed with the results. I’m now saving at least 70ms for every DNS query (after it’s been cached the first time of course.) The installation is pretty simple, and takes only a couple of minutes. I’ve logged what I have done getting it running on an Ubuntu 8.04 machine:
Notes before starting: I didn’t need much for this system setup. The machine has a P4, with 512mb RAM. The NIC was only 100mbit, and the hard drive only 40GB. I chose a box to install this on that isn’t pegged with other processes. I don’t think you need to dedicate a whole box to this project if this is for a small LAN (mine is ~10 machines), but one that isn’t constantly being used for network tasks would be a good idea (not much of an incentive to run DNS locally if it doesn’t speed up the response time.) These are just my recommendations, and it will vary depending on the size of your LAN on what you would like to setup. There are many variables differ based on your setup.
As stated before, for this installation I’m using Ubuntu 8.04. I installed the server edition, but eventually installed the ubuntu-desktop packages, because I like having the GUI when working with experimental servers. Obviously, using the ubuntu-server edition will slim the machine down and be much more efficient.
1. Open Synaptic package manager and search for “dnsmasq”. Install both packages shown by right clicking “Mark for installation”.
2. Navigate to System > Administration > Networking to open the network configuration for the machine.
3. Click on the tab “DNS”. This is the list of name servers for the machine. You can keep the original name servers in the list but press “Add” on the side and add in “127.0.0.1″, and make sure it is at the top of the list. For your secondary name servers you may want to consider moving to opendns versus using your local ISP’s.
4. Once your 127.0.0.1 entry is at the top of the list you may press OK to exit the menu.
5. To start/stop/restart dnsmasq service use the following commands:
/etc/init.d/dnsmasq start /etc/init.d/dnsmasq restart /etc/init.d/dnsmasq stop
You will most likely need to restart the service after installation and the changes you’ve made. This will also let you the service is starting correctly.
6. Now it’s time to make sure it’s working. Type the “dig” command with the website of your choice and pay attention to the query time. The first time the DNS entry will be cached, and so the second time you try the dig command on the same site the response should be significantly lower. The format is $dig WEBSITE
Another way of testing is enabling logs to syslog so that each query will be logged. You can enable logging by removing the # at the line #log-queries in the file /etc/dnsmasq.conf You will need to restart dnsmasq for changes to take effect. Syslog can be viewed from System log viewer, or any text editor. After verifying that everything was working correctly, I added the # back into the config file so that it no longer logged queries.
7. After you’ve tested all is working correctly, make sure you change the primary DNS server on the client machines to the IP address of the server you have been working on. Here are pictures that show the primary name server being changed to the local machine just setup for DNS. The examples are for Ubuntu 8.04 and Windows XP:


So that’s it. Hopefully this speeds things up for you as it did for my LAN. Thanks for reading.
