1

Dnsmasq Cache and Internal Log on USR1 signal dump (when running with or without --no-daemon and --log-queries for analysis) it always shows: 0/0 cache, meaning caching feature of Dnsmasq not working.

It is also observed that although repetitive DNS A?(host query) and A(response) records are populated successfully over the same listening interface continuously, but cache count still remains 0.

Any one having any idea how to solve/debug this Dnsmasq Cache Not Working problem ?

Alternatively, please suggest another Ubuntu linux supported DNS Caching tool which can be configured for targeted interface.

dnsmasq: cache size 150, 0/0 cache insertions re-used unexpired cache entries

root@host1:~# sudo pkill -USR1 dnsmasq
dnsmasq: query[AAAA] host1 from 127.0.0.1
dnsmasq: query[AAAA] host1 from 127.0.0.1
dnsmasq: query[A] host1 from 127.0.0.1
dnsmasq: query[A] host1 from 127.0.0.1
sudo: unable to resolve host host1
dnsmasq: time 1432979095
dnsmasq: cache size 150, 0/0 cache insertions re-used unexpired cache entries.
dnsmasq: queries forwarded 0, queries answered locally 4
dnsmasq: Host Address Flags Expires
dnsmasq: ip6-loopback ::1 6F I H 
dnsmasq: pep 127.0.1.1 4FRI H 
dnsmasq: ip6-mcastprefix ff00:: 6FRI H 
dnsmasq: ip6-allrouters ff02::2 6FRI H 
dnsmasq: ip6-localhost ::1 6FRI H 
dnsmasq: localhost 127.0.0.1 4FRI H 
dnsmasq: ip6-allnodes ff02::1 6FRI H 
dnsmasq: ip6-localnet fe00:: 6FRI H 
[1]- User defined signal 1 /etc/init.d/dnsmasq restart
root@host1:~#

TCPDUMP ON DNSMASQ Interface:

05:40:47.555213 IP 172.20.20.10.52592 > 172.20.20.2.53: 8856+ A? app.host2.com. (45)
05:40:47.558364 IP 172.20.20.2.53 > 172.20.20.10.52592: 8856* 1/0/0 A 10.60.60.190 (61)
05:41:52.875128 IP 172.20.20.10.60448 > 172.20.20.2.53: 11981+ A? app.host2.com. (45)
05:41:52.878377 IP 172.20.20.2.53 > 172.20.20.10.60448: 11981* 1/0/0 A 10.60.60.190 (61)
05:42:44.241724 IP 172.20.20.10.65300 > 172.20.20.2.53: 6667+ A? app.host2.com. (45)
05:42:44.244808 IP 172.20.20.2.53 > 172.20.20.10.65300: 6667* 1/0/0 A 10.60.60.190 (61)

Dnsmasq setting: /etc/dnsmasq.conf

log-facility=/var/log/dnsmasq.log
log-queries
log-dhcp
no-daemon
listen-address=10.20.20.15
port=53
interface=eth0
bind-interfaces
cache-size=1000
neg-ttl=3600

Dnsmasq Running as inline from default:

root@host1:~# /etc/init.d/dnsmasq restart
* Restarting DNS forwarder and DHCP server dnsmasq                                                                                   
dnsmasq: started, version 2.68 cachesize 1000
dnsmasq: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP 
DHCPv6 no-Lua TFTP conntrack ipset auth
dnsmasq: reading /etc/resolv.conf
dnsmasq: using nameserver 11.45.45.9#53
dnsmasq: read /etc/hosts - 7 addresses
User defined signal 1
root@host1:~# dnsmasq: time 1433019086
dnsmasq: cache size 1000, 0/0 cache insertions re-used unexpired cache 
entries.
dnsmasq: queries forwarded 0, queries answered locally 0
dnsmasq: queries for authoritative zones 0
dnsmasq: Host                                     Address                           
Flags     Expires
dnsmasq: ip6-allnodes                             ff02::1                        
6FRI   H   
dnsmasq: ip6-localnet                             fe00::                         
6FRI   H   
dnsmasq: ip6-localhost                            ::1                            
6FRI   H   
dnsmasq: pep                                      127.0.1.1                      
4FRI   H   
dnsmasq: ip6-mcastprefix                          ff00::                         
6FRI   H   
dnsmasq: localhost                                127.0.0.1                      
4FRI   H   
dnsmasq: ip6-loopback                             ::1                            
6F I   H   
dnsmasq: ip6-allrouters                           ff02::2                        
6FRI   H   

Dnsmasq process status:

root@host1:~# ps aux | grep dnsmasq
dnsmasq  23437  0.0  0.0  27636   936 ?        S    16:36   0:00  
/usr/sbin/dnsmasq -x /var/run/dnsmasq/dnsmasq.pid -u dnsmasq 
-r /var/run/dnsmasq/resolv.conf -7 /etc/dnsmasq.d,.dpkg-dist,.dpkg-
old,.dpkg-new

Dnsmasq package status:

root@host1:~# dpkg -l | grep dnsmasq
ii  dnsmasq                                               2.68-1                                              all          Small caching DNS  
     proxy and DHCP/TFTP server
ii  dnsmasq-base                                          2.68-1       
                                  amd64        Small caching DNS proxy 
                                              and DHCP/TFTP server
ii  dnsmasq-utils                                         2.68-1       

                                     

2 Answers 2

1

I also faced this problem and found the root cause I think.

Please capture a wireshark dump of your DNS reply and check if the "Recursion available” field is set to “Server can do recursive queries" if it is not set, then those responses will not be added to cache.

0

I've ran into the same issue. Removing listen-address in favor of interface fixed this for me - this actually looks like a bug in dnsmasq.

In regards to Arun's answer, recursion was available in my case.

Small test script:

sudo kill -usr1 $(pidof dnsmasq) for ((n=0;n<100;n++)); do dig @127.0.0.1 google.com; done sudo kill -usr1 $(pidof dnsmasq) tail /var/log/syslog

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .