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.

2 Likes

Thanks for reply.

How can we fix this ?

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

https://openwrt.org/docs/guide-user/base-system/dhcp

You also can make a static IP lease:
https://openwrt.org/docs/guide-user/base-system/dhcp_configuration

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 192.168.0.100, other is on 192.168.0.111 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.

Well.. DNS does rely on the dynamic DHCP lease information: is this wrong? When I reboot, it can take hours before the names of local machines can be resolved. Since the default for the periodic client refresh is typically long, I cannot access my local machines on Ethernet for hours (I have multiple Ethernet switches across the home).

This means no access to my HTPC for almost a day.. :frowning:

I do not reboot my router often, but it does reboot when I update OpenWRT itself. Therefore the current policy is to punish anyone applying updates. Is the intent to discourage users from applying updates?

Before a planned upgrade and/or reboot, set the lease time to a short value and make sure every device has renewed then you can reboot and they will renew again shortly. In a small network, DHCP renewals are not a significant use of bandwidth. There's no need for the default to be 12 hours.

1 Like

Thanks for the tip. I had not realized the option was server-side. Since I do not want to wait 12h before proceeding with each upgrade, I guess I will set it to a shorter time permanently..

Luci does not seem to have this config option, even in the Advanced tab (despite having obscure options such as "Max EDNS0 packet size"). Should I look somewhere else?

Otherwise, I guess I will have to go back to the command line.. :frowning:

Yes it does. Try looking at the dhcp server tab from your lan network interface. Lease time is in that section.

3 Likes

I found it right after asking the question.. sorry for the disruption. Thank you for the response.

1 Like

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