Double cache cascading improves efficiency of DNS cacheing significantly.

The clients access a small (internal) DNS cache, whith a small cache size and a low cache cycle time. The cache content changes quickly, according to the current requests.

The small cache forwards all queries to a big (external) DNS cache with an optimum cycle time (about mean TTL). The external cache does all the DNS resolution. Its content will reflect overall requests of the server.

Note: I have lost the reference to the source of this strategy. If you know it, please notify me so I can cite the person here.

External cache setup

Set up a resolver with

sudo -i

RESOLVER=dnscachex
IP=127.53.0.1

Then continue setting up the cache.

If you already know the deal, set up bigger initial values for the cache size.

The following are the default values of dnscache-conf.

cd /etc/dnscachex
echo 1000000 | sudo tee env/CACHESIZE
echo 3000000 | sudo tee env/DATALIMIT

Note:

  • Monitor the cycle time and adjust if needed. It should be greater then 3 days.

Internal cache setup

Set up a resolver at /etc/dnscache with IP address 127.0.0.1

sudo dnscache-conf Gdnscache Gdnslog /etc/dnscache

Set up smaller initial values for the cache size and forward all queries to the external cache.

cd /etc/dnscache
echo  300000 | sudo tee env/CACHESIZE
echo 1000000 | sudo tee env/DATALIMIT
echo 1 | sudo tee env/FORWARDONLY
echo 127.0.0.1 | sudo tee env/IPSEND
echo 127.53.0.1 > root/servers/@

Note:

  • Monitor the cycle time and adjust if needed. It should be between 15 minutes and 6 hours.

  • The value for DATALIMIT has been determined with a static dnscache programm compiled with diet libc.