how to flush dns of Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic x86_64)

have tried many things form here and here also but nothing is working

  • 1
    why do you think it is not working? Any stat with dig, Any error message?
    – Web-E
    Feb 3, 2014 at 11:55
  • @braiam if u have noticed that i have mentioned the same question that the solution dint worked out for me. May 28, 2014 at 6:20

2 Answers 2


According to this SU answer "How to clear DNS cache in Ubuntu?", Ubuntu by default does not provide DNS cache service. But if you have one that you installed manually, you could usually restart those services to clean the cache. Here are some examples (source):

  • Run this command to flush DNS:

    sudo /etc/init.d/dns-clean restart
  • Followup the above command with this:

    sudo /etc/init.d/networking force-reload

  • To flush nscd DNS cache:

    sudo /etc/init.d/nscd restart

  • To flush dnsmasq DNS cache:

    sudo /etc/init.d/dnsmasq restart

  • If you use BIND this should flush DNS:

    sudo /etc/init.d/named restart


    sudo rndc restart


    sudo rndc exec

    BIND (>= v9.3.0) supports flushing records from a particular domain and also the lan and wan views.source Examples:

       sudo rndc flush
       sudo rndc flushname askubuntu.com
       sudo rndc flush lan
       sudo rndc flush wan

  • 9
    This answer is spot on. As a followup, if you have not installed a DNS caching service/local DNS server, then the best course of action is probably to restart your router. Most routers have a DNS cache built-in and turned on by default that DHCP sets up.
    – Reid
    Feb 3, 2014 at 17:41
  • 1
    Thank you, both, I was going to comment above on the incomplete answers... However, this one had covered it; cool! :)
    – Nostromov
    Apr 13, 2017 at 23:36

Install nscd using the following command if not yet

sudo apt-get install nscd

Flush DNS Cache in Ubuntu by restarting the nscd

sudo /etc/init.d/nscd restart
  • there is no inbuild tools? Feb 3, 2014 at 11:21
  • 3
    no @jdog, it's not - but this one is - askubuntu.com/questions/2219/how-do-i-clear-the-dns-cache
    – cwd
    Jun 18, 2014 at 21:22
  • this did not work for me (but installation and restart commands did work fine). However, when I do ssh root@serverA, it still brings me to the old server...
    – bzero
    Aug 24, 2016 at 13:52

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