This is an old revision of the document!
By default, dnsmasq stores DHCP lease information in RAM. This means that operations like a reboot will erase the lease database, forcing a new one to be created. This could be inconvenient, since devices might receive a new IP address after DHCP renewal. For dnsmasq to maintain its DHCP lease information, your router needs persistent storage, (such as USB).
There are currently two approaches to resolving this. The first approach does not use scripting.
dhcp-leasefile=/mnt/usb/dnsmasq/dnsmasq.leases \\
2) A different approach is to keep the lease database in its default location and copy it to permanent storage at “halt” time to then restore it when the device runs the “init” at boot. e.g.
Administration/Scripts/Init
[ -f /mnt/usb/dnsmasq.leases ] && { sort -b -k 2 -u -z /tmp/var/lib/misc/dnsmasq.leases > /tmp/dnsmasq.tmp1 sort -b -k 2 -u -z /mnt/usb/dnsmasq.leases > /tmp/dnsmasq.tmp2 diff -a /tm kill -HUP `ps | grep rm /tmp/dnsmasq.tmp1 rm /tmp/dnsmasq.tmp2 }
Administration/Scripts/Halt
cp -f /tmp/var/lib/misc/dnsmasq.leases /mnt/usb/dnsmasq.leases
This method 2) can be used with any storage, JFFS included, where for USB (only) an alternative is to performed the save/copy within the Run after mounting/Run before unmounting
on the USB page instead than the generic script section.