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

オープン
#5,989 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
51/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
php

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
PHP
スター
1.2k
フォーク
932
平均マージ
1日 11時間
マージ済み PR(30日)
22

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

opnsense/plugins のほかの issue

opnsense/plugins の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。