Skip to content

pbr: add docs/tor.md reference notes - #151

Closed
egc112 wants to merge 3 commits into
1.2.3from
pbr-1.2.3-tor-reference-doc
Closed

pbr: add docs/tor.md reference notes#151
egc112 wants to merge 3 commits into
1.2.3from
pbr-1.2.3-tor-reference-doc

Conversation

@egc112

@egc112 egc112 commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

What

Adds docs/tor.md — reference notes on how Tor routing works in pbr — and links it from README.md.

Tor is the one supported "interface" that isn't a network interface, and almost everything about how it behaves has been undocumented. Between them, the docs carried a single line:

Tor tunnels supported in nft mode only (interface name must match tor).

That leaves out the five hardcoded redirect rules, which policy options are discarded, how a destination-based Tor policy depends on dnsmasq, and why a .onion setup can fail silently on a stock OpenWrt — the last of which took a long support thread to get to the bottom of.

Contents

  • The mechanism — Tor is a dstnat redirect, not a routed interface: no routing table, no firewall mark, no gateway. What that implies.
  • What pbr does, in order — detection, reading the ports from torrc, registering the synthetic interface, turning a policy into five rules, hooking the chain into fw4.
  • The five rules — and the consequence that only ports 53, 80 and 443 are ever redirected, so a Tor policy is not a kill switch.
  • Source-matched vs domain-matched policies — what each depends on, and why the second brings in a dependency pbr cannot verify.
  • Every way a domain-matched .onion policy fails quietly — ten of them, including OpenWrt's /usr/share/dnsmasq/rfc6761.conf declaring .onion local and overriding any server=/onion/127.0.0.1#9053.
  • Symptom-driven troubleshooting — starting from the one nslookup pair that splits "Tor is fine, dnsmasq is losing the answer" from "the problem is in Tor".
  • Reference torrc, the two valid dnsmasq designs, and the IPv6 TransPort trap.

Why in this repo rather than the docs site

The docs site gets a shorter, user-facing Tor section (see the companion PR below) and links here for the depth. Keeping the fiddly parts in one place stops the two copies drifting — particularly the rfc6761.conf details and the reference torrc, which would otherwise be restated in both.

Packaging

Not packaged. The Makefile installs explicit paths under files/, so docs/ is repo-only and adds nothing to the device.

Note on provenance

The file carries a header stating it was written by Claude from a support-thread investigation, and that while most of it is verified against the source, the dnsmasq and Tor manuals, and tests on a live router, some is inference. Several confident-sounding conclusions during that investigation turned out to be wrong before the real cause surfaced, and the header says so. Happy to soften or drop that if it reads wrong for a repo file.

Companion

mossdef-org/docs.mossdef.org#27 adds the docs-site section that links here. That link points at blob/1.2.3/docs/tor.md, so this PR should merge first or the published link 404s.

🤖 Generated with Claude Code

Tor is the one supported "interface" that is not a network interface, and
almost everything about how it behaves has been undocumented: the five
hardcoded redirect rules, which policy options are discarded, how a
destination-based Tor policy depends on dnsmasq, and why a .onion setup can
fail silently on a stock OpenWrt.

Adds docs/tor.md, a reference covering the mechanism end to end -- how the
rules are built and hooked into fw4, source-matched versus domain-matched
policies and what each depends on, the ways a domain-matched .onion setup
fails without any error surfacing, symptom-driven diagnostics, and the two
valid dnsmasq designs. Links it from README.md.

The docs site carries a shorter user-facing Tor section and links here for the
depth, so the fiddly parts live in one place rather than being restated and
drifting.

Not packaged: the Makefile installs explicit paths under files/, so docs/ is
repo-only and adds nothing to the device.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

Signed-off-by: Erik Conijn <egc112@msn.com>
egc112 added 2 commits August 13, 2026 12:54
The five-rule listing implied that udp dport 80/443 carry traffic into Tor.
They do not: Tor's TransPort accepts TCP only, so nothing is listening for the
UDP that gets redirected to it. The practical effect is to blackhole UDP on
those ports rather than route it -- which does stop QUIC/HTTP3 on 443 slipping
past Tor, but by refusing it, not by carrying it.

Also notes the mirror-image asymmetry: Tor's DNSPort is UDP-only, which is why
there is no tcp dport 53 rule and why adding one would redirect TCP DNS to a
port that cannot answer it.

Both confirmed against the Tor manual.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

Signed-off-by: Erik Conijn <egc112@msn.com>
The reference torrc used VirtualAddrNetwork 10.192.0.0/10 -- the deprecated
option name, and the third-party value this same file cautions against a few
paragraphs earlier. The pbr docs show VirtualAddrNetworkIPv4 172.16.0.0/12, so
a reader following both hit a mismatch.

Uses the current option name and the value OpenWrt's Tor client guide sets, and
says so, with a pointer back to the note that Tor's own default differs.

Also drops the hardcoded range from the diagram, since the paragraph directly
below it says not to assume one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

Signed-off-by: Erik Conijn <egc112@msn.com>
@egc112

egc112 commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator Author

Closing — tor.md belongs in the docs repository rather than here.

It now lives at pbr/tor.md in mossdef-org/docs.mossdef.org#27, alongside the user-facing Tor section in pbr/1.2.3/README.md that links to it. Keeping both in one repo also removes the cross-repo merge dependency this PR had, and the window where the published link would have 404'd.

No content is lost — the file is unchanged apart from a relative link back to the README section.

@egc112 egc112 closed this Aug 13, 2026
@egc112
egc112 deleted the pbr-1.2.3-tor-reference-doc branch August 13, 2026 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant