What's new

Anyone ever tried to preserve DHCP leases on restart?

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

If you are referring to existing leases then yes, they are stored in that file. It's not accessed by the HTML page, it's accessed by the httpd daemon, and probably other places within the code, so you shouldn't be messing with that.

Yeah was just confirming the code was hardcoded to that location and not to check dnsmasq.conf for it, but I guess it makes sense that it doesn't. Definitely not something valuable enough to try and mess with the code. Will see if a symbolic link works if and when I have the motivation.
 
Try creating a symlink in your postconf script.

Crossed my mind, just not as fluent in linux as I am in other things. Will look into it as it seems sensible. Wondering if the symlink is there if dnsmasq will completely recognize that as the valid file and not try to re-create it, but I guess no reason it shouldn't work with it, kinda the whole point. I guess worst case my script would have to happen a bit later and delete that file and create the symlink.
 
Crossed my mind, just not as fluent in linux as I am in other things. Will look into it as it seems sensible. Wondering if the symlink is there if dnsmasq will completely recognize that as the valid file and not try to re-create it, but I guess no reason it shouldn't work with it, kinda the whole point. I guess worst case my script would have to happen a bit later and delete that file and create the symlink.
Use dhcp-leasefile to change the file location and then create a soft link from the old filename to the new file in your dnsmasq.postconf script.
 
Use dhcp-leasefile to change the file location and then create a soft link from the old filename to the new file in your dnsmasq.postconf script.

Makes sense. I think I could even soft link the whole directory (since that is the only file in it) to a directory on JFFS which would mean I don't even need to change the location of the dhcp-leasefile, it would just get redirected there automatically, but that could potentially have other unthought-of consequences I suppose, or maybe even get overwritten. Linux may not work like windows does with links like that, again, not a big linux person.
 
@ColinTaylor @RMerlin @Yota

At first I thought it was easier than expected, simply deleting the file and creating a symlink to jffs worked, DNSMASQ could write to it and the GUI could read from it. Restarting DNSMasq kept it in place fine. But reboot of the router lost it.

So instead my dnsmasq.postconf just deletes the file from its default location and then creates a symlink to the file on JFFS. Survives a restart of dnsmasq, soft reboot, and hard reboot. DIdn't bother re-pointing dnsmasq to write to jffs directly, it follows the link fine.

For grins I'll post a tutorial, who knows maybe someone else will want to do this.

Yes the lease times are a couple mins out of synch after a reboot but since devices renew long before the lease expires, it will synch back up on its own.
 

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