OpenWrt Forum Archive

Topic: How to make dnsmasq serve static leases across reboots?

The content of this topic has been archived on 3 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Title says it all.

When rebooting my router the device "forgets" which leases it has made to my hosts.

This means that name resolution on my network stops working until my hosts automatic renews its lease or I manually do this. This is _very_ frsutrating.

There is a lengthy discussion on the subject here: http://tomatousb.org/forum/t-402699

I know I can just add the entries to a separate hosts file, but this seems like a real hack since the information is obviously there for dnsmasq. I do not use linux on my router so that I cannot conform to DRY.

So my question is: Why doesn't dnsmasq take the information provided in the static leases section in luci and serve it to me in dns requests regardless if there is an active lease or not? How can I make it do so?

While its annoying having to duplicate data, its not the end of the world in OpenWRT.

As the /etc/config/dhcp file is so well structured its easy to add a static lease and host entry at the same time and see that their IP addresses match correctly.  That's how I have done it anyway.

Perhaps it would be helpful if someone added a "sync DNS with DHCP" check box so this is done automatically when you add static leases in luci?

Alex Atkin UK wrote:

While its annoying having to duplicate data, its not the end of the world in OpenWRT.

As the /etc/config/dhcp file is so well structured its easy to add a static lease and host entry at the same time and see that their IP addresses match correctly.  That's how I have done it anyway.

How do you add a host/ip pair in the dhcp file?

Alex Atkin UK wrote:

Perhaps it would be helpful if someone added a "sync DNS with DHCP" check box so this is done automatically when you add static leases in luci?

Agreed!

Well I'm new to OpenWrt but yesterday I've configured my dhcp settings.

If you want your leases to be permanent across reboots I think you need to change the lease file. In default configuration it uses a file in tmp, so when you reboot leases are gone. I think that if you set it to a permanent file it may work. You can see the option leasefile in http://wiki.openwrt.org/doc/uci/dhcp

Good good, somebody else has already noticed this. Did anyone above solve this by moving the lease file to persistent storage?

rotmoset wrote:

When rebooting my router the device "forgets" which leases it has made to my hosts.

It does so because lease file is on tmpfs.
Why not to change the location to non-volatile partition ?
It will not forget leases across reboots

(Last edited by bolvan on 12 Nov 2013, 07:36)

Just to confirm that changing the location of the lease file (to /etc/config/dhcp.lease for example) *does* work, but the reason you might not want to do this is here:

https://forum.openwrt.org/viewtopic.php?id=32842

I've also posted an alternative solution that might be of use.

(Last edited by spammy on 11 Jul 2014, 20:35)

The discussion might have continued from here.