Repository navigation
dns: add ISP DNS unblock helper - #171
Merged
Merged
Conversation
Cd1s
force-pushed
the
feat/dns-unblock
branch
from
October 25, 2026 13:11
380a697 to
077f3f1
Compare
…he on the way back, mon loop only when enabled
R3-1 the health state machine starts from the mode resolv-lan.conf is really in (boot: the init script has
seeded the helper and there is no state yet; helper restart: the state may still say direct). The first
probe no longer rewrites a good file to the ISP resolvers for one interval.
R3-2 going back to the helper (file written, or found in the file) reloads dnsmasq and mr-proxy-dns
(rc-service ... reload = SIGHUP: cache dropped, no restart); mr-proxy-dns gets the reload command.
Going to the ISP does not flush. The monitor logs every switch it makes.
R3-3 mr-mon runs the 5 s probe loop only with --dns-unblock (MON_DNS_UNBLOCK=1 in conf.d/mr-mon, rendered only
while the feature is on); without it mon-collect is main's. Every wait of the flagged run is `cmd & wait $!`,
so TERM ends the loop and its children at once. Switching the feature off removes gen/dns-unblock.json
and the runtime files (module Orphans).
R3-5 dns.unblock.port is gone (the helper is always 127.0.0.2:53), from the struct, validation, panel default.
R3-6 docs: only mr-mon probes periodically, the cache behaviour, DNS64 clients bypass the helper, what
disabling removes.
R3-8 examples/lab.d/30-dns.yaml is main's again (dot); CI checks a copy of the lab config with unblock on.
Scenario 10 is main's except that the ISP address follows the lab id.
Lab 11: blocked.test has a TTL of 300, the cached block page must be gone after the switch back; after the reboot
the monitor's first probe must not switch the seeded helper (no retry); mr-mon stop leaves nothing; disabling
removes the files.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Cd1s
force-pushed
the
feat/dns-unblock
branch
from
October 25, 2026 17:31
28a82a9 to
59275bc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add global ISP DNS unblock support under
dns.unblock: a sing-box 1.14+ helper (mr-dns-unblock,127.0.0.2:53) evaluates ISP or manual DNS responses and retries configured block-page, private sinkhole, and empty A/AAAA/HTTPS responses through Cloudflare, Google, Quad9, or a custom trusted resolver.dnsmasq reads
/run/mini-router/resolv-lan.conf: the helper when it is healthy, the ISP resolvers when it is not.mr-mon(onlymr-mon; the WAN hooks rewrite the file when a lease changes but do not probe periodically) probes every ~5 s with two results in a row to switch, so a stopped, hung or restarted helper is recovered in about 10 s without restarting dnsmasq. Docs:docs/modules/dns.md(dns.unblock),docs/modules/mon.md.Why
Some operators return a block page address, private sinkhole, or no answer for blocked domains. The hand-managed helper depended on cron-updated single-resolver state and could take LAN DNS down when it stopped. This keeps normal ISP answers and existing split/parental/sovereignty behavior while making the fallback visible, validated, supervised, and recoverable.
Third review (R3-1…R3-6, R3-8) — what changed in this round
Rebased on main
749d8ea(#169 + #172); the one conflict,writeResolvinmr/hooks.go, keeps main's DNS64 sync once.resolv-lan.confto the ISP resolvers for ~5 sTestDNSUnblockHealthHelperFileWithoutStateStaysHelper,…HelperRestartedWhileStateSaysDirect; lab 11after reboot the monitor's first probe leaves the seeded helper alone(fails when the old initial state is put back)rc-service dnsmasq reloadandrc-service mr-proxy-dns reload(SIGHUP: cache dropped, no restart); going to the ISP does not flush.mr-proxy-dnsgets areloadcommand.…SignalsDnsmasqOnlyWhenSwitchingToHelper,…AdoptingHelperFlushesOnce; lab 11cached block page is dropped when dnsmasq goes back to the helper(blocked.test has TTL 300)mon-collectchanged for every router: atrapthat delayed TERM, asleep 5loop, a probe every 5 s forever after the feature was turned off--dns-unblock(MON_DNS_UNBLOCK=1inconf.d/mr-mon, rendered only while the feature is on, so toggling it restarts mr-mon); every wait of that run iscmd & wait $!; turning the feature off removesgen/dns-unblock.jsonand the runtime files (moduleOrphans)TestDNSUnblockMonSamplerFlagOnlyWhenEnabled(conf.d is byte-identical to main without the feature),TestDNSUnblockOrphans;tools/ci.d/mon.shruns the sampler with and without the flag in dash and busybox ash; lab 11mr-mon stop leaves no process…,disabling removes…,after disabling mr-mon has no probe loopdns.unblock.portcould only be 53TestDNSUnblockHasNoPortKeymr-monprobes; cache behaviour, DNS64 clients bypassing the helper, what disabling removes are documenteddns.upstream: dottoispexamples/lab.d/30-dns.yamlis main's again;tools/ci.d/dns.shrenders a copy of the lab config with unblock on and runssing-box check/dnsmasq --teston it. Scenario 10 is main's except that the ISP address follows the lab id (it was fixed to10.1.1.1, i.e. lab id 1).R3-9 (a second probe name) is left as is: a trade-off, not needed for this PR.
Found by the lab, not by unit tests:
supervise-daemon dnsmasq --signal HUPdoes not work outside the service's own script ("the first argument is dnsmasq and must be local"), so the first version of R3-2 sent nothing.rc-service … reloadis what Alpine's dnsmasq script itself uses.Verification
sh tools/ci.sh— ALL CHECKS PASSED (gofmt, vet,go test ./..., shellcheck, module checks incl. the newdns.shunblock lane andmon.shloop lane).11-dns-unblock: 26/26 TAP checks ok (output below);10-proxy-nat46-dns64(proxy: add built-in NAT46 and managed DNS64 #169): 2/2 ok.rc-service mr-mon stop/restartin the Alpine lab VM (busybox ash 1.37): no mon-collect,sleeporunblock-healthprocess left right after the command returns or 1 s later.portdefault) atruns/2026-10-25-minirouter-nat46-dns/feat-dns-unblock/:dns-unblock-off-360.pnganddns-unblock-on-360.png.Lab ID 8 TAP output (head 59275bc)
Automatic probing and recommendations (
mr dns unblock detect) remain a follow-up PR.Closes #170