Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I clear the DNS cache in DD-WRT on my router?

DD-WRT uses the dnsmasq daemon.

share|improve this question
Besides the technically correct answers below, you could power cycle it... – Hayden Thring Dec 16 '15 at 10:53
up vote 14 down vote accepted

According to Flush dnsmasq dns cache:

dnsmasq is a lightweight DNS, TFTP and DHCP server. It is intended to provide coupled DNS and DHCP service to a LAN. Dnsmasq accepts DNS queries and either answers them from a small, local, cache or forwards them to a real, recursive, DNS server. This software is also installed many cheap routers to cache dns queries. Just restart to flush out dns cache:

# stopservice dnsmasq
# startservice dnsmasq
share|improve this answer
There is no "sudo" on dd-wrt. There is not /etc/init.d on dd-wrt, nor any equivalent. – Hugo May 6 '12 at 3:28
Hmm... The code was just a quick example. Maybe I should delete it. Alternatively do you know the correct command for this env? – Justin Ethier May 6 '12 at 13:09
The other answer has the only way that I know of for restarting services on dd-wrt. Not too clean, but I don't know any other way. – Hugo May 6 '12 at 21:15
How about stopservice dnsmasq followed by startservice dnsmasq? See barrymorrison.com/tag/dd-wrt – Justin Ethier May 7 '12 at 2:08
Hadn't heard about it. Didn't find it after a quick google either. Great job :) – Hugo May 7 '12 at 6:35
killall -1 dnsmasq

Send HUP signal to tell it flush the cache an reread its configuration, thus starting over with a clean slate.

share|improve this answer
I think using SIGHUP is the cleanest method because the manpage notes it, and dnsmasq may not clear the cache on restart. Though I'd have put # killall -HUP dnsmasq rather than # killall -1 dnsmasq because it is easier to remember/understand. – James Haigh Apr 20 '14 at 21:51
Actually it does not cause it to reread its configuration – that part is incorrect – but that doesn't matter for the question because the configuration doesn't need to be reread to clear the cache. – James Haigh Apr 20 '14 at 22:06

Since there are no init scripts on DD-WRT, I guess this would be the easiest way to restart dnsmasq:

  1. Kill dnsmasq:

    root@ddwrt6:~# killall dnsmasq
  2. Start dnsmasq:

    root@ddwrt6:~# dnsmasq --conf-file=/tmp/dnsmasq.conf 
share|improve this answer

I've always used:

killall -1 dnsmasq

which has worked fine for me. I'm running some of the newer versions of DD-WRT and

stopservice dnsmasq
startservice dnsmasq

also seemed to work without error or needing sudo...

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.