[Dnsmasq-discuss] Controlling TTLs and Response size

Simon Kelley simon at thekelleys.org.uk
Mon Dec 2 17:18:55 GMT 2013

On 26/11/13 09:45, Nishant Rajvanshi wrote:
> We are using dnsmasq as a proxy/caching server for our network. We need a
> couple of customizations in dnsmasq  for our network:
> 1) To be able to control the  TTLs for certain IPs which are returned using
> aliases.
> so for e.g if I had an alias=,
> I want to modify the TTL when received IP was, or the returned IP
> is
> So, basically, i want to control the TTL for specific requests.
> 2) Sometimes, the responses returned by upstream servers are large. For.e.g
> a request for google.com from a client would results in 10-12 IPs being
> returned by the upstream server. We need to capture the response and be
> able to return just 1 or 2 ips to the client. This is required to reduce
> the caching of excess data and also reduce network traffic and DNS failures
> on a busy network.
> Please suggest how this can be done. I'm not a C programmer, but if someone
> can give us pointers for the changes (files/functions etc), I can attempt
> to make them.

For 1) you need to look at the function do_doctor() in src/rfc1035.c, it 
should be fairly simple to do.

for 2), I'd think quite hard if you really want to solve the problem 
that way, it sounds like a bit of a hack to me. If you do, I'd continue 
to cache all the data, but limit the number of replies 
_when_answering_from_the_cache. That way you'll still round-robin 
through all the possible replies. Look in answer_request for the loop 
which calls cache_find_by_name() and exit the loop after a few addresses 
have been retrieved.



More information about the Dnsmasq-discuss mailing list