For a printer that needs a predictable IP, add a static lease. Persistent storage matters when dynamic records must survive a router reboot. If clients have already lost DHCP, restore service first.
Identify the failing instance
Keep wired access. Temporarily assign the computer an unused address on the LAN if needed. Over SSH, match leasefile to the generated configuration and the path in the log. Ignore the odhcpd entry. Here a service restart can reuse the file, but rebooting clears tmpfs, including the path through /var.
uci show dhcp | grep -E '=dnsmasq$|[.]leasefile='
grep -H '^dhcp-leasefile=' /var/etc/dnsmasq.conf.*
ls -ld /var /tmp
df -k /tmp
logread | grep -i dnsmasq | tail -30

Restore the working path in LuCI
Export the configuration and note the original value. Select the instance shown below, restore its path and choose Save & Apply. A single instance commonly uses /tmp/dhcp.leases. Give each instance a separate file outside configuration directories. Preserve the latest active leases for that pool. Never overwrite them with a stale copy.

If the service stays down after applying, run the first line during maintenance. It restarts all instances. Replace the example path in the second line to read expiry, MAC and IP. Check the log again. Resolve any remaining error before moving the file.
/etc/init.d/dnsmasq restart
awk '{print $1, $2, $3}' /tmp/dhcp.leases
Check the external volume
Substitute your mount point for the example below, which assumes /mnt/data/dhcp/lan.leases.
grep ' /mnt/data ' /proc/mounts
ls -ld /mnt/data /mnt/data/dhcp
df -k /mnt/data
Stop if the mount is missing or the device differs. An empty directory may sit on internal flash. Check that the volume mounts before dnsmasq at boot, shows rw and has space. For No such file, run mkdir /mnt/data/dhcp only if that last directory alone is missing on the mounted volume. Startup can create the file. It needs an existing parent. For permission errors check service access without opening the whole disk. Schedule any path change for a maintenance window.
Prove that a lease survived
Reconnect a DHCP client. Check its address and gateway, match its MAC and IP in the file and resolve a familiar name through the router. Record an unexpired lease, disconnect that client and reboot during maintenance. Check the mount and record before reconnecting and renewing. The same IP alone proves little. On failure restore the working path and repeat. Return the management computer to DHCP.
Why does dnsmasq report a bad option on line 1 of dhcp.leases?
Comments