I'm trying to use dig to verify some DNS information, but I'm only seeing old results. From what I've read, Ubuntu doesn't cache DNS by default at an OS level. If that's true, then the dig command has its own DNS cache. Presumably, installing a universal DNS cache like nscd would not prevent dig from using its own cache, so my question is how do I clear the cache used by the dig command?

I realize that DNS information may not propagate right away, but if I dig @ for example, I get updated results. However, using dig normally on the same domain multiple times will reveal that all results besides the first take 0ms, so clearly there is caching going on at some level.

Edit: Here is the summary from dig superuser.com on the first try:

;; Query time: 233 msec
;; WHEN: Tue Apr 24 10:09:19 2012
;; MSG SIZE  rcvd: 113

and the second try:

;; Query time: 0 msec
;; WHEN: Tue Apr 24 10:09:58 2012
;; MSG SIZE  rcvd: 113

2 Answers 2


dig has no cache of its own, unless you run some caching daemon locally such as nscd or dnsmasq etc. If you do you just need to restart these daemons to clear the local cache, you can use +trace to see exactly where the results are coming from.

  • 2
    If I use +trace, it skips the cache and gives me up-to-date results, so that doesn't help me figure out where the cache is. It does reinforce my knowledge of a cache though, since I can immediately try the request again without +trace and still get the old results. I've checked my running processes and checked whether every caching daemon I know of is installed and I'm not finding anything.
    – Zeus
    Apr 24, 2012 at 17:01
  • if you have a local cache, dig result should show the local loop ip or something similar. what is the output of a plain dig that you are seeing?
    – johnshen64
    Apr 24, 2012 at 17:06
  • Edit: I put the results in original question, since I can't do code blocks in comments.
    – Zeus
    Apr 24, 2012 at 17:10
  • caching does not seem to be done on your local system so you don't have local dns cache, but at your dns server.
    – johnshen64
    Apr 24, 2012 at 17:13
  • 1
    It seems that it was indeed the server. I switched my DNS servers in /etc/resolv.conf to some with shorter cache lifetimes and now I get more up-to-date results. Thanks for your help. Upvote and accepted answer for you.
    – Zeus
    Apr 24, 2012 at 17:30

If you see nameserver in your /etc/hosts file, replace the line with another nameserver such as nameserver and uninstall the package resolvconf (for Ubuntu: apt-get remove resolvconf). This worked for me.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .