DHCP: expired dynamic leases are still served by DNS, shadow DNS rewrites and are hidden from the UI
Prerequisites
- [X] I have checked the Wiki and Discussions and found no answer
- [X] I have searched other issues and found no duplicates
- [X] I want to report a bug and not ask a question or ask for help
Platform (OS and CPU architecture)
Linux, ARM64 (Raspberry Pi 4), Docker
Installation
Docker (adguard/adguardhome)
Setup
On one machine; AdGuard Home acts as both DNS and DHCP server for the LAN
AdGuard Home version
v0.107.78
Action
AdGuard Home is the only DNS and DHCP server on the LAN, local_domain_name: lan, DHCP range 192.168.0.101-192.168.0.200.
-
A client receives a dynamic lease, e.g. hostname
pi4, MAC2c:cf:67:59:00:13, IP192.168.0.108(pi4is the same machine that also runs AdGuard Home). -
That lease expires (in my case
2026-09-13), but it stays indata/leases.json. -
The machine later gets a static address
192.168.0.100(netplan on eth0), so.108is not used anymore. -
DNS rewrites for the same name point to the correct address and are enabled:
- domain: pi4.lan answer: 192.168.0.100 enabled: true - domain: '*.pi4.lan' answer: 192.168.0.100 enabled: true -
A LAN client queries
pi4.lan:nslookup pi4.lan 192.168.0.100 Name: pi4.lan Address: 192.168.0.108 (dead address, no device answers on it)
Expected result
- Expired dynamic leases should not be used to answer DNS queries.
- Even if the DHCP hostname takes precedence over DNS rewrites (which is documented behaviour in the processing pipeline), an expired lease should not win over an explicit, enabled rewrite.
Actual result
pi4.lanstill resolves to the expired lease address192.168.0.108(TTL 10), so the DNS rewrite is silently shadowed and clients get an unreachable IP.*.pi4.lanworks, because no lease hostname matches those names - only the exact, expired hostname is broken. This makes the failure look random.- The same happens for every expired lease in
leases.json, e.g.rpi.lan -> 192.168.0.120(expired 2026-09-16),s8.lan -> 192.168.0.124(expired 2026-10-05),s10p.lan -> 192.168.0.114(expired 2026-10-18). - Reverse records are stale as well: PTR for
192.168.0.108still returnspi4.lan. - The expired leases are not shown in the UI, so there is no way to remove them:
Settings -> DHCP settings lists only active leases, while the expired ones keep
answering DNS queries. There is also no HTTP API to delete a single dynamic lease
(only static leases can be removed), so the only workaround is to stop AdGuard Home
and edit
data/leases.jsonby hand.
Additional information
Root cause, verified in the source of v0.107.78:
internal/dhcpd/v4_unix.go,GetLeases()filters expired leases withl.Expiry.After(now). This is why expired leases are invisible in the UI and API - the data that is actually used by DNS cannot be managed from the UI.internal/dhcpd/v4_unix.go,IPByHost()readshostsIndexwith no expiry check at all, so DNS keeps answering with expired data.internal/dnsforward/process.go,processDHCPHosts()runs beforeprocessFilteringBeforeRequest(), so a DHCP-hostname answer always wins over a DNS rewrite for the same name. That order itself is fine, but combined with the missing expiry check it makes stale DHCP data override an explicit rewrite.internal/dhcpd/db.go,dbStore()persistsgetLeasesRef()(all leases, expired included), so expired entries never age out ofleases.jsonand survive restarts.- The same
IPByHost()behaviour exists in the newerinternal/dhcpsvc/server.goonmaster, so this is not fixed by the v0.108 changes.
Related issues: #8572 (leases with zero expiry never cleaned up - that fix in v0.108.0-b.91 does not cover leases that expired normally), #3932 (PTR TTL does not respect lease time), #3934 (visibility of DHCP leases), #7673 (stale lease data affecting DNS, closed by the reporter without a fix).
Possible fixes:
- Ignore leases whose
Expiryis in the past inIPByHost()/HostByIP()and in the reverse-PTR path. - Prune expired dynamic leases when loading and storing
leases.json, so existing installations self-heal. - Show expired leases in the UI (or add a "reset dynamic leases" action), so users can clean them up without stopping the server and editing files.
Workaround used: adding a static lease with the stale lease's MAC replaces the entry
and restores correct resolution; adding a static lease with a different MAC (e.g. the
machine's eth0 MAC) fails with hostname already exists, because rmDynamicLease()
only clears the hostname but leaves the stale entry in hostsIndex.
Thank you for letting us know. The information has been forwarded to the dev team.