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 188.8.131.52
ns2.gnu.org. 86358 A 184.108.40.206
ns3.gnu.org. 86358 A 220.127.116.11
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: