6

On Ubuntu 12.04 I installed BIND9 via apt-get install.

I configure the server in a very simple way and it works in name resolution. Now I'm curious to read (if it's possible) its cache.

Reading the rndc manpage I tried to use the rndc flush view command, but it says

rndc: `flush` failed: not found

while if I run simply rndc flush it works.

So, first of all, where I can find the BIND9 cache file?

And then, why rndc flush view fails?

JustTrying
  • 239
  • 2
  • 5
  • 11

3 Answers3

11

You seem to be asking two different questions.

For the first, the cache is held only in RAM. However you can view it with rndc dumpdb -cache which will be saved (on Debian and Ubuntu) by default to /var/cache/bind/.

For the second, I think that perhaps you don't know what a view is with regard to bind.

A view is an alternate zone presented to a subset of clients. For example, if you have a private and public network you might create a public only view of your zone for external clients while internal clients will have a view for public and private networks. You can only flush a named view that is configured in named.conf (or any included files).

A view is not the same thing as a zone, and you can't individually flush zones.

bahamat
  • 6,263
  • 24
  • 28
  • Thank you for the explanation. But after I run `rndc dumpdb --cache` I can't find the file in `/var/cache/bind`. This folder contains managed-keys.bind and managed-keys.bind.jnl – JustTrying Dec 03 '12 at 09:37
  • Look in `/etc/bind/*` for the `directory` directive. This will be the location where it gets saved. And the user `bind` must have write permission for that directory. – bahamat Dec 03 '12 at 09:40
  • I know this is an OT, but I have `directory "/etc/bind/";` and I also run `chown root.bind /etc/bind/`, but the `dumpdb` file doesn't yet exist. – JustTrying Dec 03 '12 at 10:04
  • 1
    You also need to make sure that the group permission is `+w` for `/etc/bind`. – bahamat Dec 03 '12 at 19:42
  • I think a view is more like an alternative server configuration for a client set. Effectively, it is a dns virtualhost. – peterh Apr 14 '20 at 13:28
  • 1
    `rndc dumpdb --cache` won't work with bind9! Use `rndc dumpdb -cache` – Adrián Jaramillo Nov 21 '21 at 22:20
2

For example in named.conf:

options {
    ...
    dump-file       "/usr/local/etc/namedb/working/named_dump.db";
    ...
}
1

What I had to do to view the dump.db file in 2018:

sudo rndc reload

Reload the RNDC Cache

dig website.example

Give it data to cache

sudo rndc dumped -cache

Tell it to start listing cached items

cat /var/cache/bind/named_dump.db

View the cached DB - should display a standard response:

ubuntu.com. 143 A 91.189.94.40

Please note that reloading doesn't appear to affect the file after you've started inputting data.

From my experience, the caching server acts just dandy but viewing the caches files will turn up empty even if the server is working in a practical perspective (e.g. dig google.com 100ms, dig google.com 1ms and 3 mins later still 1ms resolve time). Hope this helps, it's not concrete, it works and I'd appreciate corrections on this answer where appropriate.
Note: This applied to my Ubuntu 12.04 machine and 16.04 machine. I will test Ubuntu 18.04 soon.

Tmanok
  • 197
  • 2
  • 13