This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
retain_dhcp_lease_info_after_a_reboot [2022/02/04 03:22] – added "per se". hogwild | retain_dhcp_lease_info_after_a_reboot [2023/08/09 02:13] – [Method 2: Copying the lease database to permanent storage at halt time] -clarify option for USB support hogwild | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Retain DHCP lease information | + | ====== Retain DHCP Lease Information |
- | In order to maintain | + | By default, dnsmasq stores DHCP lease data in (volatile) RAM. This means that operations such as a reboot will erase the lease database, forcing a new one to be created. This could be inconvenient, |
- | Navigate to [[:advanced-dhcpdns|DHCP/ | + | There are currently two common methods for dealing with this. |
+ | |||
+ | |||
+ | ===== Method 1: Store the lease database on permanent storage ===== | ||
+ | |||
+ | The first method does not use scripting. The goal of the first method is to store the lease database on permanent storage. | ||
\\ | \\ | ||
+ | |||
+ | - Under Advanced, go to to [[advanced-dhcpdns|DHCP/ | ||
+ | dhcp-leasefile=/ | ||
+ | </ | ||
+ | - Use a path relative to your own system. | ||
+ | - Using permanent storage means client devices won't lose connectivity if the router reboots. Because the lease database is not stored in RAM, a reboot won't erase it. This can be useful, for example, when devices are connected to a switch. Moreover, clients won't display in the [[status-devices|Device List]] as having an active lease until their current lease expires, and they' | ||
+ | - You will notice that the example points to a USB device labelled " | ||
+ | |||
+ | |||
+ | ===== Method 2: Copying the lease database to permanent storage at halt time ===== | ||
+ | |||
+ | \\ The second approach is to keep the lease database in its default location and copy it to permanent storage at " | ||
+ | |||
+ | \\ \\ For example, in the in the Init field on the [[admin-scripts|Scripts]] menu, enter:\\ | ||
<code -> | <code -> | ||
- | dhcp-leasefile=/opt/ | + | [ -f /mnt/ |
+ | sort -b -k 2 -u -z /tmp/var/lib/misc/dnsmasq.leases > / | ||
+ | sort -b -k 2 -u -z /mnt/usb/ | ||
+ | diff -a /tm | ||
+ | kill -HUP `ps | grep | ||
+ | rm / | ||
+ | rm / | ||
+ | } | ||
</ | </ | ||
\\ | \\ | ||
- | Use a path relative to your own system. | + | \\ |
- | This can be useful, for example, when devices are connected to a switch. They won't lose network connectivity if the router is down (rebooted). They won't display as having | + | in the //Halt// field In the [[admin-scripts|Scripts]] menu, enter:\\ |
+ | |||
+ | <code -> | ||
+ | cp -f / | ||
+ | </ | ||
+ | |||
+ | \\ | ||
+ | |||
+ | \\ | ||
+ | |||
+ | Method 2 can be used with any type of storage, including JFFS. When using USB (only), an alternative is to enter the above configuration lines into the //Run after mounting// or //Run before unmounting// | ||
+ | |||
+ | \\ | ||
+ | |||
+ | \\ | ||