Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 05-06-2004, 11:51 AM   #1
Registered: Feb 2003
Location: Buffalo, NY
Distribution: Novell Linux Desktop
Posts: 159

Rep: Reputation: 30
how-to flush dns cache

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

Old 05-06-2004, 01:01 PM   #2
Registered: Apr 2001
Location: Bremen, Germany
Distribution: Debian
Posts: 303

Rep: Reputation: 30
If you use bind9 that would be rndc flush. With bind8 ndc flush should do it.
Old 06-21-2007, 03:55 PM   #3
Registered: Apr 2005
Location: Minneap USA
Distribution: Debian, Mepis, Sidux
Posts: 470

Rep: Reputation: 32
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?
Old 06-22-2007, 05:34 PM   #4
Registered: Jan 2004
Location: Los Angeles
Distribution: Slack64 14.1
Posts: 568

Rep: Reputation: 38
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.

Old 03-01-2008, 05:49 AM   #5
LQ Newbie
Registered: Jun 2004
Location: Edison, NJ
Distribution: SuSE, Knoppix, Ubuntu, FreeBSD, SCO Open Server
Posts: 7

Rep: Reputation: 1
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, 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 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.
1 members found this post helpful.
Old 04-28-2009, 06:42 PM   #6
LQ Newbie
Registered: Apr 2009
Posts: 3

Rep: Reputation: 1
Very very old post... anyway

The much simpler way to flush the cache if using nscd is to invalidate its contents:
nscd -i hosts
You usually have to be root to do this.
1 members found this post helpful.
Old 07-27-2011, 03:47 PM   #7
Registered: Apr 2006
Location: Silver Spring, MD
Distribution: Debian
Posts: 40

Rep: Reputation: 8
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



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Display and Flush DNS cache click Linux - Networking 7 11-10-2009 02:00 PM
DNS losing cache vasillalov Linux - Networking 7 12-27-2007 06:16 PM
how to reload sbp2 module /Flush terminal command cache Lakota Mandriva 1 12-07-2004 03:08 PM
problems with dns-cache kokolisso Linux - Networking 0 05-17-2003 05:43 PM
DNS Cache Architect Linux - Networking 2 10-25-2002 05:02 AM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:54 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration