dns/dnscrypt-proxy: restarted on every interface link-up and can deadlock with Unbound on DoH bootstrap ("waiting for at least one server to be reachable"); ignore_system_dns is in the template but not in the model

Đang mở
#5,989 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
51/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php
Lĩnh vực
backend, networking

Hướng nghiên cứu

Read src/opnsense/service/templates/OPNsense/Dnscryptproxy/dnscrypt-proxy.toml and the dnscrypt-proxy model in General.xml; the issue says the template supports ignore_system_dns, but the model has no field for it. Then trace dnscryptproxy_configure_do() and compare its interface handling with the Unbound fix in core#11083. Done means the setting can be configured and LAN link-up no longer causes an unnecessary restart or a DNS bootstrap loop.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Important notices

  • I have read the contributing guide
  • I have searched the existing issues and found no duplicate

Describe the bug

With Unbound forwarding "." to dnscrypt-proxy (127.0.0.1:5353) and dnscrypt-proxy using a DoH server given by hostname, a LAN link-up event can leave DNS broken until manual intervention.

On link-up, rc.linkup runs the dns plugin hook. dnscryptproxy_configure_do() ignores the interface argument and always runs template reload + dnscryptproxy restart, and in the same second Unbound is reconfigured as well:

20:02:11 /usr/local/etc/rc.linkup: plugins_configure dns (,lan)
20:02:11 /usr/local/etc/rc.linkup: plugins_configure dns (execute task : dnscryptproxy_configure_do())
20:02:12 /usr/local/etc/rc.linkup: plugins_configure dns (execute task : unbound_configure_do(,lan))

dnscrypt-proxy then has to resolve the DoH hostname (dns.nextdns.io). Because the generated config always contains ignore_system_dns = false, it uses the system resolver first. /etc/resolv.conf points to 127.0.0.1 (Unbound), and Unbound forwards everything to dnscrypt-proxy, which is not up yet. The result is a resolution loop:

[2026-11-30 20:02:12] [NOTICE] Now listening to 127.0.0.1:5353 [UDP]
[2026-11-30 20:02:17] [ERROR] Get "https://dns.nextdns.io/<profile>?dns=...": context deadline exceeded
[2026-11-30 20:02:17] [NOTICE] dnscrypt-proxy is waiting for at least one server to be reachable

dnscrypt-proxy stays in that state. A direct DoH request from the firewall with curl succeeds in ~0.1 s, so the upstream is fine. Unbound additionally marks the forwarder as down in its infra cache:

unbound: error: SERVFAIL <redirector.googlevideo.com. A IN>: all the configured stub or forward servers failed, at zone . no server to query nameserver address

All names that are not cached return SERVFAIL (for example YouTube video hosts), while cached names keep working, which makes it look like a partial block. Recovery required a second configctl dnscryptproxy restart (after Unbound had the DoH hostname cached again) plus unbound-control flush_infra all. On this day there were several LAN link-up events, and each one carries this risk.

Two observations in the plugin

  1. ignore_system_dns is handled in the template but cannot be set:

    src/opnsense/service/templates/OPNsense/Dnscryptproxy/dnscrypt-proxy.toml

    {% if helpers.exists('OPNsense.dnscryptproxy.general.ignore_system_dns') and OPNsense.dnscryptproxy.general.ignore_system_dns == '1' %}
    ignore_system_dns = true
    {% else %}
    ignore_system_dns = false
    

    General.xml has no ignore_system_dns field, so this branch can never become true from the GUI/model. With ignore_system_dns = true, the bootstrap resolver (fallback_resolver, e.g. 9.9.9.9:53) would be used directly and the loop could not happen.

  2. dnscryptproxy_configure_do($verbose) restarts the service on every dns hook call, regardless of the interface. dnscrypt-proxy here only listens on 127.0.0.1:5353, so a LAN link-up does not need a restart. This is the same pattern that was fixed for Unbound in opnsense/core#11083 (c82b4c8).

To Reproduce

  1. Unbound: Query Forwarding "." → 127.0.0.1 port 5353 (Unbound as resolver for clients, dnscrypt-proxy as upstream).
  2. dnscrypt-proxy: one DoH server via hostname stamp (here NextDNS sdns://...dns.nextdns.io/<profile>), bootstrap 9.9.9.9:53.
  3. System DNS: 127.0.0.1 first in /etc/resolv.conf (default when Unbound is enabled).
  4. Trigger a LAN link-up (unplug/replug a client port or reboot the client on a single-port LAN).
  5. dnscrypt-proxy often hangs with "waiting for at least one server to be reachable", and uncached lookups through Unbound return SERVFAIL.

Expected behavior

  • A LAN link-up should not restart dnscrypt-proxy when it only listens on localhost (or at least not without need).
  • ignore_system_dns should be configurable (or default to true when Unbound forwards to dnscrypt-proxy), so the DoH hostname is resolved via the bootstrap resolver instead of through Unbound.

Workaround

An Unbound Query Forwarding entry only for the DoH hostname (dns.nextdns.io) to a plain resolver, so Unbound can always resolve it even while dnscrypt-proxy is down. (Forwarding the whole nextdns.io domain is not ideal, because then test.nextdns.io is answered by the other resolver as well.)

Environment

  • OPNsense 26.7.10p1 (amd64)
  • os-dnscrypt-proxy 1.17, dnscrypt-proxy2 2.1.15_11
  • Unbound forwarding to dnscrypt-proxy (127.0.0.1:5353), DoH upstream NextDNS
  • Intel Core Ultra 7 155H, I226 NICs
Ngôn ngữ chính
PHP
Star
1.2k
Fork
932
Merge trung bình
1 ngày 11 giờ
Pull request đã merge (30 ngày)
22

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của opnsense/plugins

Tất cả issue của opnsense/plugins

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.