opnsense / core

OPNsense GUI, API and systems backend
https://opnsense.org/
BSD 2-Clause "Simplified" License
3.38k stars 760 forks source link

Unbound host overrides breaks when adding a wildcard entry #8051

Open kriansa opened 2 weeks ago

kriansa commented 2 weeks ago

Important notices

Before you add a new report, we ask you kindly to acknowledge the following:

Describe the bug

Adding a DNS entry named * (wildcard) on a domain with an existing host override will be allowed by UI but will break Unbound initialization, thus making it immediately offline after applying the change.

According to the manual, wildcards should be accepted as host names for host overrides.

To Reproduce

Steps to reproduce the behavior:

  1. Go to 'Services', then 'Unbound DNS', then 'Overrides'
  2. Click on '+' button and add a new override
  3. Set host to "abc", domain to "opnsense.com", type A, IP address 127.0.0.1
  4. Save, then click Apply
  5. Unbound will be still running, validate running a drill @routerip abc.opnsense.com to see that it returns an entry to 127.0.0.1
  6. Click on '+' button and add a new override
  7. Set Host to '*', domain to "opnsense.com", type A, IP address '127.0.0.1'
  8. Save, then click Apply
  9. See that Unbound will stop and won't start again unless you either remove that entry or all entries that are not wildcards for that domain and apply again

Expected behavior

Unbound should stay up, and a subsequent drill xyz.opnsense.com should return an entry to '127.0.0.1'.

Environment

I don't think it's relevant.

collinthorn commented 1 week ago

I have just recently experienced the same issue. I cannot pinpoint when it started, however, as I have backup DNS that my system reverted to without me knowing. The outcome (Unbound shutting down) is the same if one were to use a different IP address in step #3 listed above.

AdSchellevis commented 1 week ago

most likely cause is an overlapping entry (e.g. *.my.org and host.my.org assigned), these are difficult to detect upfront and if I remember correctly will break startup.

fichtner commented 1 week ago

Isn't "*" the reason why domain overrides exist?

kriansa commented 1 week ago

most likely cause is an overlapping entry (e.g. *.my.org and host.my.org assigned), these are difficult to detect upfront and if I remember correctly will break startup.

Confirmed, I just tested, and this seems to be the pre-requisite for this issue. I updated the reproducing steps.

collinthorn commented 1 week ago

I dislike being on an island when it comes to error reporting. In almost every case it means I'm doing something wrong and/or stupid. My wildcard entry on Host Domains is the only entry on my list; no overlapping entries. I just have the one wildcard entry directed to my reverse proxy for keep-it-inside-LAN DNS overrides. (I think this is one application of this Opnsense functionality, yes?) As soon as I hit apply, it thinks for a bit and then Unbound turns off. When I disable it Unbound immediately turns back on.

AdSchellevis commented 1 week ago

check the logs??

rweir commented 4 days ago

@collinthorn are you doing this for the same domain your OPNSense device is, and thus generated an A record for itself?

collinthorn commented 1 day ago

@collinthorn are you doing this for the same domain your OPNSense device is, and thus generated an A record for itself?

Indeed this was my problem. I cannot speak to the more detailed use-case that is failing @kriansa in the original posting, but my Unbound no longer fails after changing my OPNsense domain.

In case of future searches: the origin of my problem was that I had attempted a Services/Unbound DNS/Overrides override for a domain that was identified as my Opnsense device domain in System/Settings/General/Domain.

It makes sense now that I see the fix but it wasn't intuitively obvious to me when I was attempting it. I very much appreciate the experts who chimed in. Cheers.