What's new

Using a /jffs/configs/dnsmasq.conf.add file

  • 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!

chiwalfrm

Regular Contributor
I want to increase the DNSMASq cache size. So I created a file /jffs/configs/dnsmasq.conf.add with a single line:
cache-size=10000

By default, the cache-size=1500, but when the router reboots, DNSMASq does not start because there are now two cache-size entries in /tmp/etc/dnsmasq.conf

pid-file=/var/run/dnsmasq.pid
user=nobody
resolv-file=/tmp/resolv.conf
no-poll
interface=br0
min-port=4096
no-negcache
cache-size=1500 <--- first one
dhcp-range=lan,192.168.0.21,192.168.0.254,255.255.255.0,86400s
dhcp-lease-max=253
dhcp-authoritative
dhcp-option=lan,3,192.168.0.3
read-ethers
addn-hosts=/etc/hosts.dnsmasq
listen-address=192.168.0.3,127.0.0.1
cache-size=10000 <--- second one

I know this is the problem because when I ssh into the router, a ps | grep dnsmasq shows it is not running. Trying to run it from shell:
dnsmasq -C /tmp/etc/dnsmasq.conf and it complains about the duplicate cache-size.

My question is how to modify the "original" dnsmasq.conf if I can't use this "add" file, or is there another way to do this with the "add" file?

Thank you
 
My question is how to modify the "original" dnsmasq.conf if I can't use this "add" file, or is there another way to do this with the "add" file?

Thank you

Edit the dnsmasq.conf file to match what you want, and save it as /jffs/configs/dnsmasq.conf. The router will use that file instead of dynamically generating a new one.

You will need to manually change that file if you ever do any change that would require it to be updated (for example, if you change the DHCP range on the webui).
 
That worked but what if the rest of the settings ever change because of a firmware update, or if I make some GUI changes that affect dnsmasq.conf? Then those changes will never get picked up in the custom one /jffs/configs/dnsmasq.conf.

Would it be feasible to add support to the firmware so that duplicate entries in the "*.add" file gets "merged" into the file replacing duplicates rather than an append?

If that is too much work, then could you tell me where the /tmp/etc/dnsmasq.conf file is copied from, so perhaps I can try modifying the original file used as a template?

Thanks very much
 
That worked but what if the rest of the settings ever change because of a firmware update, or if I make some GUI changes that affect dnsmasq.conf? Then those changes will never get picked up in the custom one /jffs/configs/dnsmasq.conf.

Would it be feasible to add support to the firmware so that duplicate entries in the "*.add" file gets "merged" into the file replacing duplicates rather than an append?

If that is too much work, then could you tell me where the /tmp/etc/dnsmasq.conf file is copied from, so perhaps I can try modifying the original file used as a template?

Thanks very much

That would be quite complicated to implement, as it would have to be on a case-by-case basis for each type of custom config files.

You will have to manually compare the dnsmasq.conf content when updating the firmware to see if there was any change. I don't expect the content of dnsmasq.conf to change a lot over time, except if Asus started to use some of the IPv6-related features of dnsmasq in a future update.
 
By way of an alternative idea... the init-start script runs before DNSmasq gets started. So I thought, maybe I could use this script to modify /etc/dnsmasq.conf.

But it didn't work because later in the boot process, my changes got overwritten.

So perhaps an additional script can be inserted into the boot process after init-start, but before the part where system services like DNSmasq get started, call it say post-init-start? Would that be hard to do? Thank you very much, Merlin.
 
By way of an alternative idea... the init-start script runs before DNSmasq gets started. So I thought, maybe I could use this script to modify /etc/dnsmasq.conf.

But it didn't work because later in the boot process, my changes got overwritten.

So perhaps an additional script can be inserted into the boot process after init-start, but before the part where system services like DNSmasq get started, call it say post-init-start? Would that be hard to do? Thank you very much, Merlin.

Not easily done, as each service can be manually restarted at any time, at which point they will recreate their config file from scratch. So for your purpose, it wouldn't work.
 
At boot time, the various config files in /tmp/etc/ (such as /tmp/etc/dnsmasq.conf) are created. They are not modified even if the service is restarted later. So we just need an additional ASUSWRT script that would insert in between the time where config files are copied/created and the step where the daemons are started (after the config files are copied).

=== boot process time line ===
init-start script runs
...
(config files copied to /tmp/etc/)
...
<--- a new script would sure be useful here
...
(daemons started)
...
pre-mount script runs
===

I can think of so many new possibilities if this was achievable. Thank you.
 
Every time a service gets restarted, its config file gets recreated. The config file generation is part of the start_*() function.
 
Every time a service gets restarted, its config file gets recreated. The config file generation is part of the start_*() function.

I'm interested in this as well. Could this be done using /jffs/scripts/dnsmasq.postconf with this code?

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

pc_replace "cache-size=1500" "cache-size=10000" $CONFIG
 
I'm interested in this as well. Could this be done using /jffs/scripts/dnsmasq.postconf with this code?

I think that would work. Why don't you try it and let us know?

Merlin added the .postconf support in December 2013 which was a few months after the OP.
 
I know this is an old thread But I am trying to append this line in the etc/dnsmasq.conf any advise woudl help

dhcp-option=lan,6,8.8.8.8,0.0.0.0
to
dhcp-option=lan,6,8.8.8.8,8.8.4.4
 
I was looking at that but did not see how it implies to doing a update to the items I listed

Update
Thinking more on this then I would use and it worked. Thanks. This corrected a small hurtle for our VoIP application to get the phones to pull the google dns. the below code was inserted into the /jffs/scripts/ folder and rebooted the router. Awesome,the results were a replaced line 19 dhcp-option set correctly. BTW Asus tech tells me it is supposed to be filled (aka 0.0.0.0) There firmware with whatever you place in the DNS1 and DNS2, I think they opened a bug n it.

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

pc_replace "dhcp-option=lan,6,8.8.8.8,0.0.0.0" "dhcp-option=lan,6,8.8.8.8,8.8.4.4" $CONFIG
 
Last edited:
I've also come across this one, you have to run dnsmaq manually to get the obscure error code re a line in the resulting config, not your add file. I think the hard-coded cache size is too small, tomato has been using 4096 for a while and it is GUI configurable, the original patch seems to be

http://repo.or.cz/w/tomato.git/commitdiff/4a4b0b8e7f816e58b6e372e69dac1332c28093af

Not a big problem for me, I will end up using a custom conf file to include domain block file from usb - but I think more users would benefit from bigger dns cache - so a feature request?
 

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