How to clear dnsmasq cache?

Discussion in 'Tomato Firmware' started by Assman, Aug 20, 2009.

  1. Assman

    Assman Addicted to LI Member

    Hey everyone,

    What's the most practical way to clear dnsmasq cache. How do I configure dnsmasq to remember entries for a fixed period of time, than flush everything and start fresh?
     
  2. phuque99

    phuque99 LI Guru Member

    It does that automatically, via DNS TTL.
     
  3. Assman

    Assman Addicted to LI Member

    And what's the default ttl?
     
  4. phuque99

    phuque99 LI Guru Member

    There's no such thing called default TTL. The TTL is always issued by the host name's nameserver and is passed on to any DNS server that queries it. Entries are cached for the duration of the TTL. DNSmasq will cache them for the duration of the TTL.
     
  5. Assman

    Assman Addicted to LI Member

    I see. Thank you :thumbup:
     
  6. fyellin

    fyellin LI Guru Member

    If you're really serious about clearing your cache, "service dnsmasq restart" will shutdown dnsmasq and then restart it.

    I'm not sure why you'd want to do this, though.
     
  7. Assman

    Assman Addicted to LI Member

    One more question. Since I'm using dnsmasq cache, should I disable windows and browser caching?
     
  8. Assman

    Assman Addicted to LI Member

    Anyone :help:?
     
  9. ntest7

    ntest7 Network Guru Member

    No.

    The DNS cache takes care of itself. You should rarely need to clear it, and never need to disable it.

    DNS caching is a well-established feature built into the DNS protocol, with built-in time limits defined by the domain you're trying to look up. This is nothing like a web cache.

    Google for "dns caching" for more info.
     
  10. Assman

    Assman Addicted to LI Member

    Thank you all for help :thumbup:
     
  11. kylejustknows

    kylejustknows Serious Server Member

    well I meet this issue as well.

    the situation is:

    1, Tomato is set using "google dns" 8.8.8.8
    2, I changed my webserver www.mywebsite.com to a new IP address on the nameserver.
    3, 10 mins later, google DNS server already updated to new IP address (checked via multiple 3rd party online tools, all google dns servers and my local dns servers are all updated to new ip address already)
    4, But visiting or ping the website.com on my PC, it still direct to old IP address, even using the "ipconfig /flushdns" to clear the dns cache on my own PC
    5, Find out that tomato is strictly follow the DNS TTL (it was very long, 24 hours). It simply won't re-check the dns no matter what, until 24 hours later. I can not wait that long and waste all day of time.

    Need a way to clear the dns cache in tomato, thats why.
     
  12. Techie007

    Techie007 Serious Server Member

    Been there several times myself. Log in to your router's config page, and execute the following command in the Tools -> System Commands section:
    Code:
    service dnsmasq restart
    And then open an administrative command prompt on your PC and execute the following command:
    Code:
    ipconfig /flushdns
     
  13. Sean B.

    Sean B. LI Guru Member

    Put:

    Code:
    clear-on-reload
    In the custom config box of Advanced->DHCP/DNS.

     
  14. eibgrad

    eibgrad Network Guru Member

    But that makes clearing the cache conditional. At any time, all you need to do is the following:

    Code:
    killall -HUP dnsmasq
    Btw, you can use the following and it will write statistics to the log.

    Code:
    killall -USR1 dnsmasq
    And if you add the log-queries directive to your config, that same command will also dump the entire cache, allowing you to confirm the results of the HUP signal.
     
  15. Sean B.

    Sean B. LI Guru Member

    It makes it less conditional than what you just stated. Clear-on-reload will clear the cache when wan disconnects/reconnects, DHCP renew etc. In addition to when it receives a SIGHUP.
     
  16. eibgrad

    eibgrad Network Guru Member

    You're confusing conditional w/ automatic. The use of clear-on-reload is automatic based on conditions, which you enumerated. I'm saying anyone, anytime can unconditionally clear the cache using the HUP signal. There are no other conditions. And if you prefer to automate it, use cron. At that point cron becomes the condition (one of time). Or if the conditions you desire happen to coincide w/ those supported by clear-on-reload, fine, use it instead.

    Frankly, the OP was never very clear about the conditions, and as such, using HUP solves the problem, whatever those conditions might ultimately be, including on-demand.
     
    Last edited: Dec 27, 2017
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice