6

Occasionally, I need to do a scorched Earth cleansing of my local DNS cachi. The most common scenario for this was that I was using OpenDNS, and when a name would fail to resolve (it was a hostname on my local network, but wasn't running), OpenDNS sends me to their lovely ad page. Then once the DNS issue is fixed, I'm still resolving to OpenDNS. That actually doesn't happen much, anymore, but still, once in a while, I just need a fresh start with my DNS.

Now, if you are likely to be able to answer my question, I'm sure you will know that modern computers hide DNS cache everywhere. Your OS has it, your browser has it, your other browser has it, if you're running DNSMasq (I am), then you have to clear that as well. So I wrote a little shell script to clear most of these caches, but the browser DNS cache still has too be done manually.

On Chrome, I go to chrome://net-internals/#dns, and click "Clear host cache"

On Firefox, I'm sure there is a similar process, I just don't know what it is.

However, I'd really like to clear both of these from the command line, so I can integrate them into my DNS-burninate script. Can this be done, and if so, how?

If Chrome or Firefox offer a command line interface to do this, that would be super cool.

If not, I assume the DNS cache is stored in a file, or set of files (is that true, or are they all stored in RAM?). If we could identify those files and delete them, perhaps that would have the same effect? Would that work, or just break everything? Where are said files?

Any other ideas?

  • +1 for 'cachi' (let's hope no one edit that out) – Jan Doggen Apr 29 '14 at 15:00
  • @Jan, I assume "cachi" is just a typo? (If you think it's the plural of "cache": the OP also used "caches". And I never see people using that.) – Arjan Apr 29 '14 at 18:45
  • I know it's 'caches'; I assumed it was a word play. And the +1 is actually for the question itself. – Jan Doggen Apr 29 '14 at 19:03
  • Yes, it was a bit of word play, 'cachi' rhymes with 'cacti'. But yes, I believe 'caches' is correct. Based on Arjan's profile, I'm assuming English is not his first language (not by your writing, it's flawless, and I applaud you). Word play is some of the hardest stuff to pickup on in another language. I probably shouldn't play such games in an international context. Sorry @Arjan! – eimajenthat Apr 29 '14 at 20:20
2

Chrome/Chromium's DNS cache is all in RAM. It appears that restarting Chrome completely will inevitably clear it.

The Chromium source for host caching doesn't appear to have any committing to the hard drive for persistence. I can only assume the official Google Chrome does the same thing.


The same goes for Firefox. It appears simply restarting Firefox will clear the cache, as the code for the prefetch system doesn't suggest it commits to the hard disk either.

  • 1
    That's a very simple solution. I like it. I'll give it a try, thanks. – eimajenthat Jul 15 '14 at 14:50
0

You can try to clean the DNS cache of Windows (or Linux)

If you use Windows then do this:
1)Run Command Prompt as Administrator
2)Write this:

ipconfig /flushdns 

and hit enter.
You can also check your DNS cache by typing this:

ipconfig /displaydns

If you use Linux then try this:
1)Open command terminal as root
2)Run the command

/etc/init.d/nscd restart

You can also use this Firefox addon to clear DNS cache: DNS Flusher

  • Why do you think this clear the browser DNS caches, like explicitly asked for in the question? – Arjan Apr 29 '14 at 18:56
  • Once it worked fine for me – Jet Apr 29 '14 at 19:15
  • 1
    @Jet, thanks for taking a stab at this, but that's the piece I can already do (pretty much like that). Arjan is right. I'm looking to flush the browser DNS caches, which are maintained independently of the system's DNS cache. – eimajenthat Apr 29 '14 at 20:25
0

open the site/page in question using a private browser window. that ignores firefox's other dns cache (which can be persistent I have found). Once having accessed the domain in the private browser window, it should work fine in a regular window. the command line option for this is:

firefox -private-window URL

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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