LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (http://www.linuxquestions.org/questions/linux-networking-3/)
-   -   how-to flush dns cache (http://www.linuxquestions.org/questions/linux-networking-3/how-to-flush-dns-cache-178589/)

PlatinumRik 05-06-2004 10:51 AM

how-to flush dns cache
 
what is the command used to flush the local cached dns on fedora core 1.

Thanks

demian 05-06-2004 12:01 PM

If you use bind9 that would be rndc flush. With bind8 ndc flush should do it.

lefty.crupps 06-21-2007 02:55 PM

And old thread, but without an answer for us desktop users who are looking for this information and are not running domain name servers on the desktop...

Does anyone have an answer for non-DNServer machines?

MQMan 06-22-2007 04:34 PM

If you're not running a DNS server on the machine, then nothing is cached, unless it's WinBlows. You will always be asking a DNS server for the info.

Cheers.

KEYofR 03-01-2008 04:49 AM

Of _course_ you may be caching dns even if you are running a "desktop" install.
There are several things that may be caching, any of several full dns servers, any of several local caching-only servers, and of course your upstream dns server probably caches to the limit allowed/specified in the ttl setting fo rthe particular record being looked up.

The most common caching daemon on linux these days (yes, running on "desktop" insalls) is nscd.
To clear it's cache takes 3 things:
stop the daemon, ensure the persistent option for the hosts service isn't enabled in nscd.conf or manualy wipe the persistent db, start the daemon.
How you stop & start the daemon, where nscd.conf is found, where the persistent db file is found, all depend on your particular distribution, but a generic answer that works on _most_ distributions is:

/etc/init.d/nscd stop

Verify /etc/nscd.conf has this:
persistent hosts no
shared hosts yes

/etc/init.d/nscd start

Or just stop the daemon and leave it stopped and don't worry about any config options or db files.
It will come back up at next reboot.

Sometimes even though the above works, there may also be a more convenient command.
Example, on SuSE, the above works, but there is also:
rcnscd stop
rcnscd start

This may not make much difference or help you though. DNS records have a TTL (time to live) field which specifies how long a nameserver may cache this particular record locally. Most nameservers cache all records for as long as TTL allows. So, your upstream dns server (whatever is listed in /etc/resolv.conf) and it's upstream dns server, and so on... all the way to whatever dns server is the authoritative nameserver for the record being fetched, will all most likely be caching that record for however long the TTL is for that record. Every record has it's own TTL value. A common TTL is 1800, which is 30 minutes, but in special cases like dyndns.org, they set very short TTL's on their records by default because they know the IPs will change often, because that is the whole point of dyndns.org in the first place. Also, since 2004-09-15 nscd already honors the TTL the same as all the other nameservers do. This means nscd will already perform a new lookup instead of supplying a record from cache no sooner than, and just as soon as, all the upstream dns servers.

So, for 2 different reasons, there is generally no point in clearing your local cache, it generally won't make a lick of difference.

zatricky 04-28-2009 05:42 PM

Very very old post... anyway

The much simpler way to flush the cache if using nscd is to invalidate its contents:
Code:

nscd -i hosts
You usually have to be root to do this.

kabars_edge 07-27-2011 02:47 PM

how-to flush dns cache
 
I know this is a very old post, however, for those of you looking for an answer, here it is.

If you are running a workstation install of any Linux and your machine is caching DNS entries while NOT running bind, rscd or nscd; then the easiest way to clear that cache is to bounce the interface.

root:~# ifdown eth0
root:~# ifup eth0

or sudo if you prefer.

user:~$ sudo ifdown eth0
user:~$ sudo ifup eth0

HTH,


All times are GMT -5. The time now is 11:37 AM.