Persistent dhcp leases

Hi,
I am sharing a little tweak that I use to make dhcp leases persist across restarts. I need this because I depend on local dynamic name resolution a lot and when turris restarts it forgets all the local dns entries created based on DHCP hostnames.

The disadvantage of this is more wear on the flash storage but the traffic on my lan is minor and the flash storage is comparatively huge so I am not worried.

You can enable persistant dhcp & dynamic dns records by storing this in /etc/init.d/dhcp-persistance

#!/bin/sh /etc/rc.common

START=15
boot() {
  if [ -f /etc/dhcp.leases ]; then
    echo "Found persistent leases. Linking /tmp/dhcp.leases to /etc/dhcp.leases"
    ln -s /etc/dhcp.leases /tmp/dhcp.leases
  fi
}

and running

cp /tmp/dhcp.leases /etc/
/etc/init.d/dhcp-persistance enable

Question: I just opted for giving out static leases for such devices, and so far I assumed that this would essentially re-populate the DSN quickly (but admittedly having a small network I mostly access hosts via their IPv4 addresses directly).

I do not know as I don’t use static leases :man_shrugging:

Ah, I started doing this since with fixed leases PaKon shows actual names instead of ip addresses, which makes looking at PaKon logs (which I do rarely) considerably easier.

Hmm, I would usually just change option leasefile in /etc/config/dhcp. Does that not play well with pakon?

Unfortunately that is not possible due to paths hardcoded here: net/resolver-conf/files/dhcp_host_domain_ng.py · master · Turris / Turris OS / Turris OS packages · GitLab