Skip to content

Unbound DNS: not properly forwarding #9641

@phreed

Description

@phreed

Important notices

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

Describe the bug

The generated /var/unbound/unbound.conf contains a relative path for the python module that fails to resolve:

python:
python-script: unbound-dnsbl/dnsbl_module.py

While this script is for DNSBL it seems to be present whether the DNSBL is enabled or not.

This causes Unbound to fail silently.
The service starts but DNS forwarding does not fully work.
External domain queries return empty answers dispite the upstream DNS servers being reachable and functional.

To Reproduce

  1. Go to Services → Unbound DNS → Query Forwarding
  2. Configure forwarding to upstream DNS servers
  3. Click Apply
  4. SSH to router and run: unbound-checkconf /var/unbound/unbound.conf
  5. See error:
    error: pythonmod: can't open file unbound-dnsbl/dnsbl_module.py for reading
    fatal error: bad config during init for python module
    

I suspect that only steps 4 & 5 are actually necessary.

Expected behavior

The generated unbound.conf could use an absolute path that resolves correctly:

python:
python-script: /var/unbound/unbound-dnsbl/dnsbl_module.py

Or the relative path should resolve correctly within the configured chroot environment.

Describe alternatives you considered

  1. Manual edit: Editing /var/unbound/unbound.conf to use the absolute path /var/unbound/unbound-dnsbl/dnsbl_module.py passes validation, but configctl unbound restart regenerates the config with the broken relative path.

  2. Disable DNSBL: Disabling the Blocklist feature should remove the python module directive thus allowing DNS forwarding to work correctly. This does not seem to have an effect on the python-script element.

  3. Symlink: Creating a symlink to make the relative path resolve - not fully tested.

Screenshots

Config validation failure:

root@mesolab-router:~ # unbound-checkconf /var/unbound/unbound.conf
[1769108850] unbound-checkconf[71749:0] error: pythonmod: can't open file unbound-dnsbl/dnsbl_module.py for reading
[1769108850] unbound-checkconf[71749:0] fatal error: bad config during init for python module

Manual fix passes validation:

root@mesolab-router:~ # vi /var/unbound/unbound.conf  # change to absolute path
root@mesolab-router:~ # unbound-checkconf /var/unbound/unbound.conf
unbound-checkconf: no errors in /var/unbound/unbound.conf

Restart reverts the fix:

root@mesolab-router:~ # configctl unbound restart
OK
root@mesolab-router:~ # unbound-checkconf /var/unbound/unbound.conf
[1769109579] unbound-checkconf[54582:0] error: pythonmod: can't open file unbound-dnsbl/dnsbl_module.py for reading
[1769109579] unbound-checkconf[54582:0] fatal error: bad config during init for python module

DNS symptom - query via Unbound returns empty:

root@mesolab-router:~ # drill @127.0.0.1 cloud.foo.edu
;; ANSWER SECTION:
(empty)

Direct query to upstream works:

root@mesolab-router:~ # drill @10.2.189.78 cloud.foo.edu
;; ANSWER SECTION:
cloud.foo.edu.	300	IN	A	10.2.218.115

Generated config shows correct chroot but broken python path:

server:
chroot: /var/unbound
directory: /var/unbound
...
python:
python-script: unbound-dnsbl/dnsbl_module.py

Additional context

The forwarding configuration itself is correct:

forward-zone:
    name: "."
    forward-addr: 10.4.162.82
    forward-addr: 10.2.189.78

The issue is isolated to the DNSBL python module path preventing Unbound from initializing properly.
As this interfers with the full processing of unbound.conf it may affect other settings from working as well.

Environment

OPNsense 25.7.11_2 (amd64)

Hardware:
Protectli
Model: V1410
Intel ® N5105 Quad Core CPU at 2.0 GHz
Intel® I226-V 2.5Gigabit Ethernet NIC

Metadata

Metadata

Assignees

No one assigned

    Labels

    supportCommunity support or awaiting triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions