Last updated

Clear DNS Cache on your router

I currently have a Linksys router at home that has the DD-WRT Firmware on it. I’ve been using it for quite some time now, and I’m very happy with it.

In my previous post I mentioned there was some trouble with DNS for Ariejan.net. I’ve changed nameservers and there’s always something that goes wrong.

Anyway, my router runs DNSMasq, a caching nameserver for my local network. (What this does is, it stores DNS queries and when the same request is made later on, the response is already here (on my network), and my ISP’s nameservers don’t have to be queried. This makes for a great speed optimalization!)

The problem was, that my router was caching parts from the old and parts from the new nameservers for Ariejan.net. I could have waited 24-48 hours to let DNSMasq figure it all out by itself, but I’m not that patient. What I needed to was reset the cache DNSMasq had built.

What you need to do is login to the admin panel of your router and enable SSH access (for your own network, not for the outside world!).

You SSH to your route, probably as the ‘root’ or ‘admin’ user. In this case the IP is your routers IP address.

1$ ssh -l admin 10.0.0.1

Once you’re in, you can issue the killall command to issue the ‘HUP’ signal to DNSMasq. This does not kill your DNSMasq, but tells it to flush the cache an reread its configuration, thus starting over with a clean slate.

The ‘HUP’ signal has the number ‘1’ so you can run the following command once logged in:

1$ killall -1 dnsmasq

Now you can logout, and notice that your cache was indeed cleared.

This method should work on every Linux based router that uses DNSMasq and support SSH logins.