DHCP lease file erased while rebooting system

Is it expected behaviour in openwrt ?

Yes, state is volatile and stored only in RAM. Storing DHCP leases for dynamically assigned IPs on flash would contribute significantly to flash wear, read kill your device's flash prematurely.


Thanks for reply.

How can we fix this ?

You can change location of that file with the "leasefile" setting in DHCP config:


You also can make a static IP lease:

This will allow some devices to keep same IP after restarting, but other to keep floating.
For example - i have around few Raspberry PIs and Orange Pis. If i keep them leasing from DHCP pool i can't reconnect later because SSH complain about mismatch between keys and IPs. I need to edit ssh_config file just to delete keys, IPs and then to login again.

That's why i make static lease for some devices and servers. So one of mine RPi always is on, other is on and so on.

1 Like

What is the actual problem?

A client with an existing lease should ask to renew it

1 Like

For recurring clients you should configure static DHCP leases, outside of the dynamic pool and with a fixed hostname. Relying on dynamic DHCP is, besides the flash wear issue, a very unreliable approach.