New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unbound doesn't know about DHCP lease that expires then appears again #4714
Comments
There is a logic bug in
Consider the following scenario:
Not updating |
@gwjo I'm not sure I agree, the only delete on cached_leases I could find was this: core/src/opnsense/scripts/dns/unbound_dhcpd.py Lines 132 to 134 in 889e24c
after which |
Cleanup local data cache when a DHCP endpoint expires, so that it is kept in sync with dynamic changes. This ensures that if an expired DHCP endpoint returns and is assigned the same IP address the local cache is correct and doesn't block the entry being dynamically re-added to Unbound. Also don't cache the blacklist entries, which aren't needed to manage the DHCP DNS entries. There can easily be 1M+ blacklist entries, so ignoring these improves startup speed and reduces memory footprint Fixes opnsense#4714
@AdSchellevis, that is the "problematic" delete. This removes the entry from core/src/opnsense/scripts/dns/unbound_dhcpd.py Lines 149 to 156 in 88e463c
You are correct that it still gets written to |
Unbound restarts is how I've handled the DHCP not reappearing historically, yes. It seems you might have found the problem 👍 |
@gwjo got it, thanks for the PR! |
Cleanup local data cache when a DHCP endpoint expires, so that it is kept in sync with dynamic changes. This ensures that if an expired DHCP endpoint returns and is assigned the same IP address the local cache is correct and doesn't block the entry being dynamically re-added to Unbound. Also don't cache the blacklist entries, which aren't needed to manage the DHCP DNS entries. There can easily be 1M+ blacklist entries, so ignoring these improves startup speed and reduces memory footprint Fixes #4714
Important notices
Before you add a new report, we ask you kindly to acknowledge the following:
Describe the bug
I have a laptop I shut off nightly. When I power it on again next day, it doesn't appear in DNS. To date, I have restarted unbound after this happens (it happens about 75% of the time), assuming something had crashed (unbound was until recently very crashy), and the laptop immediately resolves again.
I installed a monit monitor on the dhcp watcher, because that seemed to be the most likely culprit, but it hasn't crashed and seems to be working fine. In fact, everything seems to be correct except unbound itself - which knows not about the DHCP lease.
I'm guessing that the dhcp watcher somehow removed the lease from unbound, and unbound refuses to accept the new lease?
To Reproduce
Steps to reproduce the behavior:
Expected behavior
DHCP and DNS should work reliably together, no matter the status of the in-and-out of the individual DHCP requests.
Describe alternatives you considered
I'm tempted to abandon DHCPD and unbound and go to dnsmasq, but I know that's not the direction of the project, so not sure.
Relevant log files
From /var/unbound/dhcpleases.conf
So it looks like the dhcpleases knows about the cweeks-lap entry.
From
clog /var/log/dhcpd.log | fgrep cweeks-lap
We can see that the request is made when the laptop starts.
From /var/dhcpd/var/db/dhcpd.leases
There was a second "dormant" entry in here earlier, but it has since been removed by the DHCP process I guess.
The second entry above was present in the DHCP leases file above the first entry for sometime.
unbound-control -c /var/unbound/unbound.conf list_local_data | fgrep cweeks-lap.
returns nothing (and the DNS fails to resolve)NOTE:
If I run the command from #4597
unbound-control -c /var/unbound/unbound.conf local_data "cweeks-lap.*.* IN A 10.0.0.103"
and
unbound-control -c /var/unbound/unbound.conf local_data "103.0.0.10.in-addr.arpa. IN PTR cweeks-lap.*.*"
then I can now resolve the machine. Is the watcher somehow ignoring the updated lease because it was present, then it wasn't and now it is again?
Environment
Software version used and hardware type if relevant, e.g.:
Hardware is a little intel box:
Intel(R) Core(TM) i3-4030U CPU @ 1.90GHz (4 cores)
The text was updated successfully, but these errors were encountered: