[Dnsmasq-discuss] cache size & /etc/hosts

Simon Kelley simon@thekelleys.org.uk
Thu, 16 Dec 2004 19:56:07 +0000

Gyorgy Farkas wrote:

> I'm confused. What is the situation now with the size of cache
> and the size of memory - allocated for /etc/hosts ?
> 2.0.x series of floppyfw has dnsmasq version 1.2 (because of size;)
> 2.9.x series has version 1.18
> (and I'm using version 2.15 on ffw-2.9.13).
> Thank you in advance,
> George.

OK. Here's the situation.

Very old versions of dnsmasq used cache slots to hold names from 
/etc/hosts, so there was a hard limit on the number of names in 
/etc/hosts which was the cache size, and the number of names that would 
be cached was <cache size> - <names in /etc/hosts>

All non-ancient versions of dnsmasq allocate memory for names in 
/etc/hosts separately, so the number of names in /etc/hosts is limited 
only by the virtual memory size of the machine (ie it's very big). Cache 
slots are not used for names from /etc/hosts, so the number of names 
which can be cached is just the cache size.

The cache size defaults to 150 on some versions of dnsmasq and 300 on 

The cache size can be changed by a comand-line flag or /etc/dnsmasq.conf 
option. Attempts to increase the cache size too far will be ignored. 
That limit used to be 2000, I think. From version 1.14 it was upped to 

Versions of dnsmasq prior to 1.14 do a linear search through the cache 
and names from /etc/hosts, so having either lots of names in /etc/hosts 
or a very large cache could make things run slow. From version 1.14 the 
search is hashed, and runs much faster when searching a big cache or 
lots of /etc/hosts names.