30

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

DD-WRT uses the dnsmasq daemon.

Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
Bobo
  • 403
  • 1
  • 4
  • 6

6 Answers6

24

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
Justin Ethier
  • 16,686
  • 9
  • 43
  • 55
20
killall -1 dnsmasq

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

limon
  • 301
  • 2
  • 5
  • 2
    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
  • 2
    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
6

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 
    
Gilles 'SO- stop being evil'
  • 807,993
  • 194
  • 1,674
  • 2,175
ron
  • 61
  • 1
  • 1
2

Restart the dnsmasq service, either from the user interface.

Or from the command line interface via

/init.d/dnsmasq restart
sean
  • 121
  • 1
2

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...

Phil
  • 21
  • 1
1

On 21.02 this is what worked.

service dnsmasq restart
ki9
  • 364
  • 4
  • 15