View and clear Bind DNS server’s cache

As DNS admin it is useful to know how to both view and clear the cache of a Bind server. This can be for a number of reasons but for me its often down to slow DNS lookup, which leads to a sluggish web experience. This is often caused by an issue with the cache, its either gone stale or corrupt (I often don’t bother working out which one).

Viewing the cache

To view your current cache contents execute the following on your bind server

rndc dumpdb -cache

This command will normally dump bind’s cache into a file located at /var/cache/bind/named_dump.db

Clearing the cache

If you just want to skip straight to clearing the cache you can execute the following commands

rndc flush
rndc reload

I’m not sure if the reload is strictly needed but I have never found it to hurt and it may help clearing out other structures.

If you have regular problems with this you can always add those commands into cron to execute at a low usage time.

Clear specific domain

You can clear just one DNS name from the cache using

rndc flushname <the.full.domain.name>
i.e.
rndc flushname www.google.com

Or you can clear an entire domain tree using

rndc flushtree <domain.name>
i.e.
rndc flushname google.com

This would remove all domain name entries from the cache under google.com.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Create a website or blog at WordPress.com

Up ↑

Design a site like this with WordPress.com
Get started