Flush DNS cache changed in Lion

Discussion in 'Mac OS X Lion (10.7)' started by HenryAZ, Oct 16, 2011.

  1. macrumors regular

    HenryAZ

    Joined:
    Jan 9, 2010
    Location:
    South Congress AZ
    #1
    After a bit of beating my head against the wall yesterday, trying to flush out the local resolver cache, I finally learned it has changed a bit under Lion.

    In 10.6, and prior, the method was to issue

    dscachutil -flushcache

    from a Terminal prompt.

    This no longer works, as I learned trying to flush an Address record I knew had changed (because I changed it myself on one of my domains). The new record had propagated on the Internet, and dig was getting the proper response from various external servers. But anything using the local resolver cache kept getting the old IP address, even after "flushing" with the old command.

    I tracked it down by doing a dump of the local cache into system.log

    sudo killall -INFO mDNSResponder

    before and after using the old flush command. The old record remained in the cache, along with lots of others.

    I dragged out my 10.6.8 external disk and booted from it. When you issue the old command (dscacheutil -flushcache) under 10.6, the following line is logged to system.log:
    Oct 16 10:37:54 helios mDNSResponder[12]: SIGHUP: Purge cache

    and of course the cache is flushed.

    Using the old command under 10.7, there is no "Purge cache" being logged, and the cache remains intact.

    What works under 10.7 is:
    sudo killall -HUP mDNSResponder

    That logs the purge, and flushes the cache.
     
  2. macrumors 68030

    kbmb

    Joined:
    Mar 13, 2007
    Location:
    NH
    #2
    Thanks for this. Was wondering if the old method worked or not.

    -Kevin
     
  3. macrumors newbie

    Joined:
    Nov 13, 2011
    #3
    Flush cache

    Hello,

    I've used this command before as you said and it worked fine, now I am trying to do the same in another computer (Mac 10.7 Lion as well) and it isn't working. I keep getting the old results. Can you help me???

    Thank you so much
     
  4. thread starter macrumors regular

    HenryAZ

    Joined:
    Jan 9, 2010
    Location:
    South Congress AZ
    #4

    I just tried my two systems again (updated to 10.7.2 now), and this Terminal command still works here:

    sudo killall -HUP mDNSResponder

    The easiest way to see if it worked (easier than examining the cache contents), is to open Console, look at system.log, and look for a line similar to this resulting from the command:

    Nov 13 15:12:48 helios mDNSResponder[12]: SIGHUP: Purge cache


    You might really be flushing the local resolver (on that workstation), but perhaps your router is also caching records in its name server? I don't know if home routers do that as normal procedure, as I don't regularly use their (the routers') DNS services.
     
  5. macrumors newbie

    Joined:
    Nov 13, 2011
    #5
    flush cache

    Thank you for the quick answer. Well, I did what you said and it appears as you mentioned. Actually, it worked but as soon as I went online it went back to the old numbers again.

    I am not really an expert...:)
     
  6. macrumors newbie

    Joined:
    Nov 3, 2006
    #6
    Thank you

    I was searching for a reason why Lion flushdns did not work. THANK YOU!
     
  7. macrumors newbie

    Joined:
    Oct 3, 2007
    #7
    Had to use Lion command on Snow Leopard?

    Strangely, I had to use the killall command on Snow Leopard (10.6.8) to get the cache to flush - the dscacacheutil command wouldn't work. I've used that command plenty of times in Snow Leopard, but probably with earlier versions. Could it be that Snow Leopard and Lion both use the new command now? Or is there something else about system configuration that requires one vs. the other?
     
  8. thread starter macrumors regular

    HenryAZ

    Joined:
    Jan 9, 2010
    Location:
    South Congress AZ
    #8
    It appears the dscacheutil command is simply a shortcut to the killall -HUP method. The giveaway is what is logged on a successful flush, identical by either method:
    Oct 16 10:37:54 helios mDNSResponder[12]: SIGHUP: Purge cache

    I am unsure why it (dscacheutil) doesn't work for you on Snow Leapord; it does for me, and does not on Lion. Perhaps there is another reason besides simply OS version? I am wondering if dscacheutil -flushcache works for anyone on Lion? I tried it on two Lion installs, but though they are different hardware, they are both set up identically to my liking, and maybe that has something to do with it?

    At any rate, it is hardly ever super-useful, as the records can be cached several places.
     
  9. macrumors newbie

    Joined:
    Oct 3, 2007
    #9
    Snow Leopard vs Lion

    I wonder if dscachutil fails silently if you don't use sudo? I'll have to try that next time I get a chance.
     
  10. macrumors newbie

    Joined:
    Sep 15, 2011
    #10
    In my testing under 10.7.3 'sudo dscachutil -flushcache' doesn't work (no pause while cache is flushed, no log of purge as when the killall method is used) but the killall method does.

    Just as an aside, I also found that MainMenu v2.1.2 (1412)'s Flush DNS option works under 10.6 and 10.7
     
  11. adt
    macrumors member

    Joined:
    Jan 5, 2004
    Location:
    Perth, Western Australia
    #11
    Anytime you'd like to spell it correctly, there is the option of typing:

    dscacheutil -flushcache
     
  12. macrumors 68020

    sidewinder

    Joined:
    Dec 10, 2008
    Location:
    Northern California
    #12
    Spelled correctly, it still doesn't work. You need to use:

    sudo killall -HUP mDNSResponder

    As HenryAZ stated...

    Also, that command works as stated on my Mac Pro (Early 2008) running Mac OS X 10.7.3. Here is the output to "/var/log/system.log":

    May 9 01:13:10 Mac-Pro mDNSResponder[36]: SIGHUP: Purge cache

    S-
     
  13. macrumors 68020

    sidewinder

    Joined:
    Dec 10, 2008
    Location:
    Northern California
    #13
    Just tested Mac OS X 10.7.4 and you still need to use:

    sudo killall -HUP mDNSResponder

    S-
     
  14. macrumors newbie

    Joined:
    Jul 15, 2012
    #14
    Warning?

    When I entered the "sudo.." command I receive the following warning...


    WARNING: Improper use of the sudo command could lead to data loss
    or the deletion of important system files. Please double-check your
    typing when using sudo. Type "man sudo" for more information.

    To proceed, enter your password, or type Ctrl-C to abort.​


    I'm currently a novice at all of this, so just want to make sure I'm not doing something wrong before I enter my password and ruin my system!
     
  15. macrumors member

    Joined:
    Jun 14, 2012
    #15


    Everyone gets that message the first time they run sudo, it's normal and not in itself something to worry about. However, running sudo is dangerous if you're not sure what you're doing.
     
  16. macrumors newbie

    Joined:
    Oct 3, 2007
    #16
    Right - it's a legacy message that's been around much longer than the Mac. For most average users, you can muck things up much worse without sudo. In the worst case, you have to reinstall the OS, but say, you drag your iPhoto lib to the trash and you're not backed up - you're really hosed then.
     
  17. macrumors newbie

    Joined:
    Mar 22, 2012
    #17
    so before you flush it if your trying to look at it it was dscacheutil -cachedump -entries host... what would it be now??
     
  18. thread starter macrumors regular

    HenryAZ

    Joined:
    Jan 9, 2010
    Location:
    South Congress AZ
    #18
    sudo killall -INFO mDNSResponder

    dumps the cache to the System Log (Console).
     

Share This Page