Repository navigation
Policy routes by domain, hardware offload kept (#36) - #62
Merged
Merged
Conversation
…fwmark) policy_routes entries accept `domains:` / `domains_file:` (subdomains included) next to mac / src / dst. dnsmasq (both instances; the proxy's skips its fake-ip names) puts upstream answers into per-policy nft sets; only a NEW connection's first packet is matched and marked, after which the connection keeps its WAN through the ct mark and goes into the flowtable (PPE / WED) like any other. Learned addresses expire after a day without new connections (a new connection restarts the timer); firewall reloads carry them over unless the domain list changed. No new process. The image switches to Alpine's dnsmasq-dnssec-nftset (+nettle, ~0.65 MB); install.sh too. Tests: rendering, validation, files, the carry-over; CI: real nft + dnsmasq --test, and an end-to-end test in three network namespaces with a real dnsmasq. Closes #36
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
policy_routes[]acceptdomains: [example.com, …]anddomains_file: /abs/pathnext tomac/src/dst(all conditions must match; a domain covers its subdomains).pr_<i>_4/pr_<i>_6(nftset=). The policy rule marks only a NEW connection's first packet with the WAN's fwmark; the connection keeps its WAN through the ct mark and goes into the flowtable (PPE / WED) like any other — line rate stays.domains_file, a bad line reported by line number, empty lists refused; at most 16 domain policies (keeps eachnftset=line under dnsmasq's 1024 bytes). An empty set keeps its rule (never degrades into "match every destination").dnsmasq-dnssec-nftset(adds nettle, ~0.65 MB installed);install.shswaps to it where Alpine has it (3.20+). Web UI: a 目标域名 column on 策略路由. Docs: net / dns / proxy / platform, the skill cheat sheet.Why
Choosing a WAN by domain usually means sending every packet through a userspace proxy or marking every packet in software — both lose the hardware offload that carries normal traffic at line rate. Marking only the first packet keeps the offload.
Verification
dnsmasq --test; new end-to-end test intools/ci.d/net.shwith three network namespaces and a real unprivileged dnsmasq: the learned domain's traffic leaves via wan2, other traffic via wan; addresses survive a reload; a new connection restarts the timer; a changed list starts empty.tools/ci.shpasses (private and public trees).no-nftset) needs the new image before configuringdomains:; otherwise dnsmasq refuses the config and the apply rolls back.Follow-ups (to be filed): IPv6 source prefix vs. the chosen WAN on dual-PD setups; explicit first-match / last-match order of policy routes; learned-address counts in the UI.
Closes #36
https://claude.ai/code/session_01HWeUjo1dmS7gBkCYHrVjCr