What's new

Can't change Dnsmasq cache size

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Azuse

New Around Here
Hi,

I've been trying to increase the (quite small) dns cache size to 10000 unsuccessfully, despite several reboots.
I suspect that the problem likely lies with me :(. The steps taken are below. If anyone can tell me where I'm going wrong it would be greatly appreciated!

Code:
cd /jffs/scripts/

vi dnsmasq.postconf

*i

#!/bin/sh
CONFIG=$1
source /usr/sbin/helper.sh

pc_replace "cache-size=1500" "cache-size=10000" $CONFIG

*esc

:wq

reboot x3.
 
Do your have the running of scripts enabled in the gui (I think it's on the Administration tab?
Did you make the script executable with chmod?

But, there's been a lot of looking at the cache size for dnsmasq......as of yet nobody has documented a need to increase above the default (cache entries automatically expire based on the TTL, so expanding it does no good)
 
/custom scripts are enabled in the gui and chmod was run. If I try and execute the script manually (sh*) then it give me the following error:

Code:
sed: -i requires an argument

I don't really do much scripting and I can't work out what I've done wrong :(
 
Do your have the running of scripts enabled in the gui (I think it's on the Administration tab?
Did you make the script executable with chmod?

But, there's been a lot of looking at the cache size for dnsmasq......as of yet nobody has documented a need to increase above the default (cache entries automatically expire based on the TTL, so expanding it does no good)
In my experience increasing the size does more harm than good for dnsmasq.
10000 would most likely bring it to it's knees.
Or at the least mae it work erratic.
It is best left at 1500, that's plenty of cached domains and they get refreshed reasonable soon if they change.
 
I use 8192 for cache-size - via a custom dnsmasq.conf which I found easier than using script commands to create, but of course needs more tlc when firmware version or other standard options enabled via gui. Why? I can't remember I have been doing this for a long time! http://www.linksysinfo.org/index.php?threads/dnsmasq-cache-optimization-and-howto.23076/

You can check cache performance entering the following from a command line, then checking the log

killall -s USR1 dnsmasq

Mar 13 16:29:35 dnsmasq[12555]: cache size 8192, 0/40598 cache insertions re-used unexpired cache entries.
Mar 13 16:29:35 dnsmasq[12555]: queries forwarded 43771, queries answered locally 309845
 
/custom scripts are enabled in the gui and chmod was run. If I try and execute the script manually (sh*) then it give me the following error:

Code:
sed: -i requires an argument

I don't really do much scripting and I can't work out what I've done wrong :(

You need to give the dnsmasq conf file as a parameter when testing, should be found at /etc/dnsmasq.conf
 
In my experience increasing (10 years running tomato) it drastically improves things in my environment, though I appreciate it's not for everyone. I must admit I miss the gui implementation of custom config in tomato :)

You need to give the dnsmasq conf file as a parameter when testing, should be found at /etc/dnsmasq.conf

Would it be possible to explain how? My understanding of the postconf from reading is create the file then make executable.
 
postconf scripts expect to be passed a parameter ($1) that is the name of the file to be modified. The router does this automatically at startup. If you're trying to run the script from the command line you will have to supply this parameter yourself.

./dnsmasq.postconf /etc/dnsmasq.conf
 
Ok. That I understand.

What I'm trying to do is simply increase the cache size. From what I've read I'm simply trying to a dnsmasq.postconf running at startup that will achieve that. I've been unable to find a simple guide to doing this and despite my best intentions I clearly lack the understanding to do so :(
 
Ok. That I understand.

What I'm trying to do is simply increase the cache size. From what I've read I'm simply trying to a dnsmasq.postconf running at startup that will achieve that. I've been unable to find a simple guide to doing this and despite my best intentions I clearly lack the understanding to do so :(
Create, or add the part starting with CONFIG to:
/jffs/scripts/dnsmasq.postconf
Code:
#!/bin/sh

CONFIG=$1
source /usr/sbin/helper.sh
pc_replace cache-size=1500 cache-size=10000 $CONFIG
Then make it executable:
Code:
chmod a+rx /jffs/scripts/*
Make sure the file has unix line endings:
Code:
dos2unix /jffs/scripts/*
Then restart dnsmasq:
Code:
service restart_dnsmasq
Voila, simple as that.
 
Last edited:
Might want to put quotes around that just to be safe.
There's no need to, as it runs on all my routers that way, it is in the experimental settings (es) in the latest AB-Solution, 10000 is the highest setting I allow.
But I might add it to it, just to be on the safe side.
Thanks.
 
I'm sorry for digging up an old thread, but I've just moved house and trying to do this again from the beginning on the most recent release. I thought that I finally understood what I was doing but it seems that I'm still missing something.

Now, if I attempt to copy the steps in post #11 I reach can get no further than

pc_replace cache-size=1500 cache-size=10000 $CONFIG

before being told the -i requires an argument. Also I do not appear to be able to create the dnsmasq.postconf file in the beginning. I think.
 
If you have correctly created the files you should invoke them by rebooting the router or by using the following command:

service restart_dnsmasq
 
Rebooting appears to have no effect. I assume this mean I have failed to correctly create the file.

Would it be possible to show me how to do this correctly?
 
The easiest way to create and edit the required file is to use winscp which needs to login to the router using SSH.
 
Last edited:

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top