What's new

dhcp lease store on jffs

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

Shonk

Senior Member
does anyone know of a simple way of getting the dhcp lease's
stored in jffs or nvram to survive reboots

whilst not a huge problem
i would like valid leases to survive
to prevent the following all the time

Aug 14 06:48:15 dnsmasq-dhcp[282]: DHCPRELEASE(br0) 192.168.0.252 * unknown lease
 
Not too hard.....you need to make two scripts (I've been running this way for a long time).

1st, dnsmasq.postconf in /jffs/scripts (I put the leases file in a new directory /jffs/tmp, create the directory first with mkdir)
Code:
#!/bin/sh
CONFIG=$1
source /usr/sbin/helper.sh
 
pc_insert "pid-file=/var/run/dnsmasq.pid" "dhcp-leasefile=/jffs/tmp/dnsmasq.leases" $CONFIG
 
exit

2nd, you need to make an init-start in /jffs/scripts (you need this so the firmware can find the leases file for the System Log page)
Code:
#!/bin/sh
 
# Symlink to non-volatile dhcp lease file
ln -s /jffs/tmp/dnsmasq.leases /tmp/var/lib/misc/dnsmasq.leases
 
exit
 
Does dnsmasq start before or after mounting USB storage? Depending on how many clients you have on your network you might not want something as frequently modified as DHCP lease data eating away at the finite number of nvram writes available.
 
This is a nit compared to everything else already being saved in jffs....by default a copy of the syslog is periodically written there as well as data from the TrendMicro engine.
 
i have syslog writes to jffs disabled
wastes fare too many nand writes..
dont have trend problem as i have an ac66
 
i have it working
though it seems to be touching the file quite often

i think the better solution
would be on every reboot save a copy
and on power up restore it

so it will only result in one nand write per reboot
 
I think the leases file is also used by networkmap, so may be accessed regularly.

I bow out here......the discussion on the impact of nand writes and the specs of the chips used in the routers has been beat to death in multiple threads. If it's a concern to you, feel free to pursue it. For me, I've relegated it to the list of things I'm not going to worry about.
 
I have it setup to copy the file from jffs on start and shutdown now

this also stops the slowdown when pressing the DHCP leases tab
using your method

init-start

Code:
#!/bin/sh

cp /jffs/dnsmasq.leases /tmp/var/lib/misc/dnsmasq.leases

exit

services-stop
Code:
#!/bin/sh

cp /tmp/var/lib/misc/dnsmasq.leases /jffs/dnsmasq.leases

exit
 
Last edited:
If you are going to take that approach, I'd also add a cron job to periodically refresh the copy. In the event of a power fail, you could be left with a severely out of date leases file.

OR: I believe it's possible to trigger a script whenever dnsmasq makes a dhcp assignment. See the man page for details.
 
Last edited:
i have never had a power failure
i live in the uk not vietnam

if there is one the dhcp server will correct the lease file anyway

its a good compromise with low nand writes
 
Not too hard.....you need to make two scripts (I've been running this way for a long time).

...

2nd, you need to make an init-start in /jffs/scripts (you need this so the firmware can find the leases file for the System Log page)
Code:
#!/bin/sh
 
# Symlink to non-volatile dhcp lease file
ln -s /jffs/tmp/dnsmasq.leases /tmp/var/lib/misc/dnsmasq.leases
 
exit


John, thank you! I know this is an old post but the information posted here showing and explaining what's needed to allow the firmware to access DHCP information from the lease file has allowed me to view both DHCP lease and wireless client details through the GUI interface. I do a lot of my configuring using the command line interface and use of Merlin's user scripts and configs files (including using my own dnsmasq.conf file) and this has been a big help.
 
Last edited:

Latest threads

Sign Up For SNBForums Daily Digest

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