How to remove old/stale entries in the DHCP Static Leases Menu

Hi Everyone!
I've been getting a few APs set up after flashing to OpenWRT, but I noticed that the menus when adding a static lease under Network -> DHCP and DNS -> Static Leases seem to have a bunch of old addresses from when I was getting the AP initially set up. Is there a way to clean up the entries for IP and MAC address? I wasn't able to find a way to do so or a file somewhere that holds them.
Thanks!

(The non-standard button you seek doesn't exist in OpenWrt.)

You can also lower the lease time.

Well, that's not really what I was going for. See the screenshot below. I've got a bunch of old/stale IP/MAC combos in those lists and I can't figure out where they're coming from. The device isn't attached to the 172.17.1.x subnet anymore, but they're still in the list

Use SSH to connect router:
rm /tmp/dhcp.leases
/etc/init.d/dnsmasq restart

Delete entire lease file. This will clear all current DHCP leases and will request new leases as needed.

1 Like

There are a few things that are not entirely clear from your description and screenshots:

  • Are the "stale" entries in the static leases menu or in the general DHCP lease table?
  • Assuming the general lease table, has the actual DHCP lease expired?
    • Note that just because a device is no longer connected does not mean that the lease is stale -- it's only actually stale after it has expired. (for example, the default lease time is 12 hours; even if a device connects just for a minute and then is disconnected, the lease is still valid for the full 12 hours since it was issued).

The general lease table is stored in RAM. This means it does not persist across reboots, so all old leases will be cleared simply by rebooting the router and/or deleting the lease table per @AlanDias17 's comment. But importantly, even when a lease has been cleared from the router from actions like this, the client devices that obtained leases still have a valid claim to said lease until the actual lease expiration. So this shouldn't be viewed as a way to "free up" the leases, and it can cause problems at times if you've changed the DHCP server configuration (for example, using sequential IPs instead of the standard Dnsmasq config that uses a pseudo-random address out of the pool that is based on a hash of the client MAC address).

Apologies, those entries only show up in the static lease modal in the IP address and MAC address options.

In theory, a reboot should clear those (assuming they're not connected to the network anymore and that there are no static leases currently defined with those MACs).

1 Like

Not sure why it worked that time, I could've sworn that I had rebooted it several times trying to get rid of 'em, but this time it finally worked. Thanks for the assist!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.