Most people are vaguely aware that Windows by default includes a service that keeps track of your favorite sites and stashes the DNS reference (IP address) so it won’t have to keep asking for the same address. Even laptops do it. We call that a “caching only namesever.” Most Linux distributions don’t do by default this for historical reasons.
If you run a search for how to set it up on Linux, chances are you’ll get instructions suitable for servers, but not for a simple desktop system, much less usable for a laptop. You’ll see references to a service called BIND. Or maybe you’ll run into references to something for Debian called “dnsmasq” — again, the instructions are almost invariably for servers, not for desktop machines.
Okay, the instructions are usually in there somewhere, but there is an ambiguity because you see all these other details that don’t apply and somehow the article fails to clarify that. On Debian desktop systems in particular it’s very simple, just four steps.
1. Install dnsmasq — Actually if you are running a typical desktop installation, a part of it is already there; it comes in the same package as Network Manager. That’s the ethernet symbol somewhere on your desktop that you can click to connect or disconnect from whatever networks are available. However, you’ll need a couple of other files that aren’t included by default. So install the full dnsmasq
package from your Debian repository. That’s the name of the package.
2. Tell NetworkManager to use it — Log in as root and navigate to /etc/NetworkManager/
and edit the file NetworkManager.conf
. Right near the top you’ll see a bracketed reference to “main” and you’ll need to add this line somewhere close to that. Mine looks like this:
[main]
plugins=ifupdown,keyfile
dns=dnsmasq
There may be other stuff in that file, but that’s not our concern here. Just make sure you have that third line that tells Network Manager to refer to dnsmasq for DNS queries. Save the file.
3. Set a high cache limit — Our dnsmasq service keeps it’s cache in RAM. When you reboot it goes away and you have to start over. But you have to tell it how much to keep until then. Still logged in as root, navigate back out to the /etc
folder and edit dnsmasq.conf
. Now this is a big file with lots of stuff in it, but you’ll need to scan down to about line 539 and look for a reference to “cache-size.” If it has a hashmark (#) in front, remove that. Then add a number like this:
cache-size=1000
Unless you really don’t do much on the Internet, that’s probably a good minimal number. On the other hand, unless you are always online and very eclectic, you aren’t likely to need more than 3000, so that’s a good maximum. So choose a setting between 1000 and 3000 and save the file.
4. Restart the Network Manager — Still logged in as root, run this command from a terminal window:
systemctl restart NetworkManager.service
That’s it. Now your Network Manager is using dnsmasq and your browser requests for DNS addresses should be faster for anything you’ve already visited between reboots of the system.