Skip to content

nft: never TPROXY a client DNS query redirected to the router - #6

Merged
Asofwar merged 1 commit into
mainfrom
claude/project-thread-ljw5go
Oct 17, 2026
Merged

Asofwar merged 1 commit into
mainfrom
claude/project-thread-ljw5go

Conversation

@Asofwar

@Asofwar Asofwar commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner

Requested by Andrei

Описание изменений

Before: when any LAN device sent a DNS query to a resolver whose IP is in a captured list (for example 8.8.8.8 through the Google lists), the router's own DNS on 192.168.1.1:53 stopped answering everyone except the source-aware DNS clients. Wi-Fi phones then used real IPs and their traffic bypassed Prokop "sometimes".

After: a query redirected to the router is never sent to TPROXY, and dnsmasq keeps answering the LAN.

Что изменено

  • prokop/files/usr/lib/nft/apply.uc: ct status dnat return is now the first rule of the proxy chain.
    • Cause: mangle (priority -149) marks the first packet of a flow before dns_redirect (-101) rewrites it. The redirected query reached proxy (-100) addressed to the router's :53 (or :1603) and still marked. sing-box answered it from a transparent socket bound to 192.168.1.1:53, and that socket then took the LAN queries meant for dnsmasq and never read them.
    • Effect: a redirected packet is already delivered locally. Later packets of such flows were already skipped by mangle's own ct status dnat return.
  • tests/nft_apply.sh: new check that proxy starts with ct status dnat return. It fails on origin/main and passes with the fix.
  • Router evidence (prokop 2.30.5, read-only):
    • 9 sing-box UDP sockets on 192.168.1.1:53 had full receive queues and drops.
    • conntrack: the source-aware PC got 24 of 24 DNS answers; every other client got 0 (iPhone 0/12, Galaxy 0/29).
    • nslookup to 192.168.1.1 from the router: 10 of 10 timed out; to 127.0.0.1: 10 of 10 answered.
    • nft -c insert rule inet ProkopTable proxy ct status dnat return passes the router's nft check. The rule was not applied.
  • Tests:
    • Full suite in WSL: 511 tests, 7 failures. All 7 also fail on origin/main in this environment: the *_real nft tests (WSL nft has no fib), device_traffic, urltest_override_validation, and the aggregate run.
    • ucode -c passes on all .uc files; git diff --check is clean.

mangle (priority -149) marks the first packet of a flow before
dns_redirect (-101) rewrites it. A LAN query to a resolver inside a
captured list (8.8.8.8 via the Google lists) reached the proxy chain
redirected to the router's :53 (or :1603) and still marked, so sing-box
answered it from a transparent socket bound to 192.168.1.1:53. That
socket then took the LAN's queries meant for dnsmasq and never read
them: DNS for every client except the source-aware ones timed out until
the socket expired, and phones fell back to real IPs outside Prokop.

The proxy chain now returns for DNAT packets before any TPROXY rule.
@Asofwar Asofwar self-assigned this Oct 17, 2026
@Asofwar
Asofwar merged commit 46ea346 into main Oct 17, 2026
10 checks passed
@Asofwar
Asofwar deleted the claude/project-thread-ljw5go branch October 17, 2026 10:36
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