Centos – How to flush local DNS cache in CentOS

cachecentosdnsPROXY

I'm looking for a way to flush the local DNS cache on a CentOS 6.

The system is not running any DNS server or anything, and I wish to let every DNS query go out to the configured nameserver, even for the duplicate ones.

Most of what I found online tell me to do service nscd restart, reload or do nscd -i hosts. However, none seems to flush the cache.

So I'm wondering if anyone has an idea on how I might do this. Is there some kind of switch in the kernel I need to flip? Any kind of work around is fine as well.

Best Answer

Its not your local box which is caching the DNS requests but it is the DNS resolver which you are using in your /etc/resolv.conf who is caching.

To prevent to get those cached queries reply:

  1. Change the resolver.

    $ dig @<resolve-ip> www.google.com

  2. Flush the DNS cache on the resolver, if you can access the DNS server.

    $ sudo /etc/init.d/bind restart

Related Question