PuppyIP Resource Center
Network & Connection Troubleshooting 11 min Published 2026-11-17

PassWall2 Per-Device Routing Is Bypassed: Check Whether the Direct-DNS IPSet Returns Before TPROXY

When a phone does not follow its expected proxy rule, check whether a direct-DNS destination is returned before TPROXY.

PassWall2 per-device routing nftables TPROXY DNS IP set

Service eligibility and regional restrictions

PuppyIP serves only compliant overseas businesses and their authorized personnel. Proxy services are not available in mainland China. The service may only be used for lawful business activities outside mainland China. Use of this service within mainland China is prohibited.

Hosting a proxy IP or server overseas does not change these restrictions. The service must not be provided to end users in mainland China through relaying, forwarding, sharing or resale. Before use, read the Terms of Service.

Key Takeaways

  • This bypass applies only to a specific PassWall2 version with source-IP-only routing and default direct DNS; it is not a general explanation for routing failures.
  • Correlate the device source address, direct-DNS destination, IP-set membership and nftables order. Seeing an IP set or a working SOCKS5 proxy alone does not establish the cause.
  • Consider changing write_ipset_direct from 1 to 0 only when the direct-DNS destination set returns before TPROXY and the current option is 1.
  • Back up PassWall2 config and record the old value first; restarting the service interrupts proxy traffic. Roll back only this option if the check fails.

Confirm that per-device routing is being bypassed

If a LAN device should use a PassWall2 proxy but still connects directly, first confirm that it matches the source-IP rule and uses the expected gateway and DNS. Repeat the same request from that device and record the application result, router connection tracking and PassWall2 rule hit. A working explicit SOCKS5 connection proves that the proxy entry point is available; it does not prove that transparent traffic follows the intended rule.

This diagnostic branch covers only one PassWall2/Xray setup with source-IP-only routing and default direct DNS. Domain-based rules, other DNS interception methods, cores or versions need to be checked against their own generated configuration. Do not apply this option just because another setup has a similar symptom.

Compare the DNS destination set with TPROXY order

Read the active nftables rules and locate the destination set PassWall2 uses for direct-DNS addresses, along with the relevant return and TPROXY rules. A bypass is plausible only when the device's DNS request targets an address in that set and the corresponding return runs before transparent proxy redirection. Do not publish a full ruleset containing client addresses or internal subnets.

Also read the actual UCI value of write_ipset_direct. An option name in a config file, a static rule or the mere presence of a set does not prove runtime bypass. Correlate the device's source rule, destination-set membership and active rule order.

Read the option and nftables rule order

sh
uci show passwall2 | grep -F 'write_ipset_direct='
nft list ruleset | grep -n -E 'passwall|tproxy|redirect|return'
Read configuration and rules in an OpenWrt/KWRT shell. Output may include LAN addresses, set members and interface names; compare it locally and redact it before sharing.

Change one PassWall2 option only when the conditions match

Consider setting the option to 0 only after confirming all of these conditions: source-IP-only rules, default direct DNS, the destination is in the direct-destination set, return precedes TPROXY and write_ipset_direct=1. If any condition is false, stop this branch and continue checking the active policy, device source address and DNS path.

Keep a wired LAN management path and record the complete UCI option key and old value from the read-only check. The steps below change only that key and back up the full PassWall2 config to a root file with mode 600. It contains sensitive node configuration, so keep it on the router. Restarting the service briefly interrupts proxy traffic.

Back up config and set the confirmed option to 0

sh
set -eu
UCI_KEY='REPLACE_WITH_EXACT_OPTION_KEY_FROM_READ_ONLY_OUTPUT'
CURRENT="$(uci -q get "$UCI_KEY")"
[ "$CURRENT" = '1' ] || { printf 'Expected write_ipset_direct=1; stop and recheck\n' >&2; exit 1; }
umask 077
BACKUP="/root/passwall2-before-write-ipset-direct-$(date +%Y%m%d-%H%M%S)"
cp /etc/config/passwall2 "$BACKUP"
chmod 600 "$BACKUP"
uci set "$UCI_KEY=0"
uci commit passwall2
/etc/init.d/passwall2 restart
Run only when all conditions above are true, the exact UCI key identifies the active global option and its old value is 1. Replace the key and use a maintenance window; do not publish the node configuration backup. If the restart fails, use the single-option rollback below.

Recheck the same device and request

After restarting the service, confirm the option is 0, the direct-DNS destination is no longer returned early by that generated set and the expected TPROXY path remains. Repeat the same request from the original test device. Use rule counters, connection tracking and actual egress to confirm the request entered the proxy; checking the router's SOCKS5 port alone is not enough.

This repair path does not include a device reboot test. If reboot persistence matters, record the current successful state and schedule a separate maintenance check with wired management available. Do not treat one phone request after a service restart as acceptance for every device, DNS mode or software version.

Roll back only the changed option

If the same phone request still bypasses the proxy, a new DNS failure appears or PassWall2 does not restart cleanly, stop changing DNS, global IP sets, nodes or firewall rules. Restore write_ipset_direct to the value recorded before the change, commit it and restart PassWall2. Run the command below only when the router's actual state matches its precondition.

After rollback, check the UCI value, generated rules and the same request from the original device. Keep the config backup until the repair or rollback has been verified. It may contain node and authentication settings; store it with restricted access and handle it under the device's normal security policy.

Restore the previous write_ipset_direct value

sh
set -eu
UCI_KEY='REPLACE_WITH_EXACT_OPTION_KEY_CHANGED_ABOVE'
PREVIOUS_VALUE='1'
[ "$(uci -q get "$UCI_KEY")" = '0' ] || { printf 'Setting is not 0; stop and inspect current state\n' >&2; exit 1; }
uci set "$UCI_KEY=$PREVIOUS_VALUE"
uci commit passwall2
/etc/init.d/passwall2 restart
Replace PREVIOUS_VALUE with the value recorded before the change. Run only if the current value is still 0. This restores one UCI option and restarts PassWall2; it does not revert other later config changes.

Keep the version and acceptance limits in view

This behavior is tied to PassWall2 26.10.20-r152, Xray 26.3.27 and a specific rule combination. Do not infer defaults or rule-generation order for other versions. The change was not checked across a device reboot; persistence requires a separate check.

DNS interception, the final egress address and client access are different acceptance points. Disabling direct-address writes tests only whether the identified destination-set path changes. It does not replace broader DNS, TCP, UDP, IPv6 or other source-policy testing.

Sources

Frequently Asked Questions

Should I disable write_ipset_direct for every PassWall2 routing issue?

No. Consider it only for source-IP-only routing with default direct DNS, when the destination is in the set and its return rule runs before TPROXY.

Does working explicit SOCKS5 prove transparent proxy rules work?

No. It checks the SOCKS entry point and proxy chain. Verify transparent forwarding, rule hits and actual egress from the original LAN device.

Can I clear all DNS IP sets or rebuild all nftables rules?

Do not use global cleanup as a generic fix. Identify the exact destination set, member and rule order first; if the conditions match, change only this option.

Does the change prove that a reboot will work?

No. First verify the same-device request after the service restart. Persistence across a full router reboot is a separate acceptance step.