DNSMasq view cache entries and cache size used

Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking
Author Message
bobs
DD-WRT User


Joined: 24 Jan 2016
Posts: 98

PostPosted: Mon Feb 08, 2016 17:12    Post subject: DNSMasq view cache entries and cache size used Reply with quote
How can I view cache entries and cache size used on DNSMasq in DD-WRT via SSH?
Sponsor
h8red
DD-WRT Guru


Joined: 28 Jun 2011
Posts: 580
Location: Vilnius, Lithuania

PostPosted: Mon Feb 08, 2016 17:19    Post subject: Reply with quote
cat /tmp/dnsmasq.leases | wc
_________________
[Ramips] Nexx WT3020F Openwrt @kernel #4.14.167 (OpenVPN server, Wireguard server, AD blocking, SQM QOS, USB)
bobs
DD-WRT User


Joined: 24 Jan 2016
Posts: 98

PostPosted: Mon Feb 08, 2016 17:26    Post subject: Reply with quote
h8red wrote:
cat /tmp/dnsmasq.leases | wc


That is DHCP leases not DNS Entries

I am trying to optimise my DNS cache size to actual use over a period of time.
bobs
DD-WRT User


Joined: 24 Jan 2016
Posts: 98

PostPosted: Mon Feb 08, 2016 21:55    Post subject: Reply with quote
DNSMasq stores DNS cache in ram, is there any way to read this or at the very least, the NUMBER OF ENTRIES in the ram cache?
bobs
DD-WRT User


Joined: 24 Jan 2016
Posts: 98

PostPosted: Mon Feb 08, 2016 22:44    Post subject: Reply with quote
eibgrad wrote:
From the DNSMasq documentation:

Quote:
-q, --log-queries
Log the results of DNS queries handled by dnsmasq. Enable a full cache dump on receipt of SIGUSR1. If the argument "extra" is supplied, ie --log-queries=extra then the log has extra information at the start of each line. This consists of a serial number which ties together the log lines associated with an individual query, and the IP address of the requestor.


Problem is, I'm not sure if dd-wrt supports the log-queries option, or whether it will respond to signals. At least it didn't work the last time I tried it. It's one of the limitations of dd-wrt when it comes to DNSMasq. Many features have been stripped out to save space, or sometimes it's just running older versions of DNSMasq that never supported the feature.

Note, you would add the directive to "Additional DNSMasq Options" as follows:

Code:
log-queries


Restart DNSMasq:

Code:
stopservice dnsmasq && sleep 5 && startservice dnsmasq


Then from the command line, signal for the dump.

Code:
killall -USR1 dnsmasq


Btw, works on tomato.


Ill open a bug to get it to be able to show the DNS cache COUNT in use and remaining then.
bobs
DD-WRT User


Joined: 24 Jan 2016
Posts: 98

PostPosted: Mon Feb 08, 2016 23:00    Post subject: Reply with quote
eibgrad wrote:
P.S. Should have mentioned, these dumps are made to the syslog, NOT the command line.


I don't really want to list each query and so forth, just a count will do, perhaps even on the UI would be nice, DNS cache used / total / remaining etc.
mac913
DD-WRT Guru


Joined: 02 May 2008
Posts: 1848
Location: Canada

PostPosted: Tue Jun 06, 2017 4:35    Post subject: Reply with quote
Here's another way to view DNS Cache via CLI. I added these commands to the GUI DNSMasq Options...

# Log the results of DNS queries with EXTRAs
log-queries=extra
# Best to store DNS Cache in file for viewing
log-facility=/tmp/DNSCache.log


To view the DNS Cache entries, telnet or SSH to the router and type...

cat /tmp/DNSCache.log

_________________
Home Network on Telus 1Gb PureFibre - 10GbE Copper Backbone
2x R7800 - Gateway & WiFi & 3xWireGuard - DDWRT r53562 Std k4.9

Off Site 1

R7000 - Gateway & WiFi & WireGuard - DDWRT r54517 Std
E3000 - Station Bridge - DDWRT r49626 Mega K4.4

Off Site 2

R7000 - Gateway & WiFi - DDWRT r54517 Std
E2000 - Wired ISP IPTV PVR Blocker - DDWRT r35531


YAMon 3.4.6 | DNSCrypt-Proxy V2
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum