A configured domain name service ( DNS ) server such as Bind may store previously resolved domain names to a local cache. By default the cached records will be stored for 7 days. The cache can be reused for future domain name resolutions. First, let's see how we can view all cached domain name resolutions:
# rndc dumpdb -cache
The above command will dump bind's cache into /var/cache/bind/named_dump.db. In case you cannot locate this file after you have executed the above command then check your server's configuration files to reveal the location of cache dump file. To view cached dns records simply cat or grep the resulting dump file. For example:
# grep gnu.org /var/named/data/cache_dump.db
gnu.org. 86358 NS ns1.gnu.org.
86358 NS ns2.gnu.org.
86358 NS ns3.gnu.org.
ns1.gnu.org. 86358 A 208.118.235.164
ns2.gnu.org. 86358 A 87.98.253.102
ns3.gnu.org. 86358 A 46.43.37.70
Clear cache
The following linux commands will assist you if you wish to clear your Bind server's cache. First, flush all cache entries:
# rndc flush
Once done, reload bind:
# rndc reload
server reload successful
If there were no DNS queries after you flushed bind's cache and reloaded DNS your new cache dump file will be empty: