pbr: main_chains cleanup flushes fw4 forward chain and breaks DNS resolution
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- linux, shell
- Domain
- networking
Research direction
Start at net/pbr/files/etc/init.d/pbr, in cleanup(main_chains) near line 1295, and check how the chain name is built for the forward entry. Confirm the fix flushes the PBR-owned chain while preserving fw4's base chain, then validate with the package build and a policy rebuild that requires fresh DNS lookups.
Written by the indexing model from the issue text.
Description
Package Name
pbr
Maintainer
@stangri
OpenWrt Version
25.12.5 r33051-f5dae5ece4
OpenWrt Target/Subtarget
x86/64
Steps to Reproduce
Environment: PBR and luci-app-pbr 1.2.2-r20, fw4 nft file mode, OpenWrt 25.12.5 r33051-f5dae5ece4 on a Proxmox x86/64 VM, kernel 6.12.94. LuCI: openwrt-25.12 branch 26.207.72448~3727980.
-
Use
resolver_set='none'with domain policies routingifconfig.co,github.comandraw.githubusercontent.comvia WAN. The failure also occurs withstrict_enforcement=0;procd_reload_delay=5was already configured. -
Configure OpenWrt's dnsmasq to use a Pi-hole on the LAN. Pi-hole queries its local Unbound, which forwards to VPN DNS servers. Unbound's upstream traffic therefore passes through OpenWrt to reach
tun0. -
Switch Unbound's upstream DNS servers from OpenVPN hooks:
route-up /etc/openvpn/up.sh route-pre-down /etc/openvpn/down.sh -
Trigger a full PBR policy rebuild during a VPN connection transition. Observe a rebuild that requires fresh upstream DNS answers; cached answers can mask the failure. For comparison testing, the DNS caches on OpenWrt, Pi-hole and Unbound were cleared.
-
Inspect PBR's resolution errors and active nft rules. Capture DNS on both OpenWrt and Pi-hole with
tcpdump -i any, filtering the formatted output to the affected domain names.
The issue was intermittent before the local fix. After the one-line PBR fix, fresh DNS tests and extended testing succeeded.
Actual Behaviour
PBR intermittently reported Failed to resolve during full policy rebuilds. The affected domains then lacked their IPv4 destination rules. A later successful DNS query did not automatically restore those rules.
PBR service error messages
PBR itself reported the following errors during the failure window captured on November 18 (chat-escaped punctuation normalized):
Wed Nov 18 17:31:40 2026 user.notice pbr [19335]: ERROR: Failed to resolve 'ifconfig.co'!
Wed Nov 18 17:31:40 2026 user.notice pbr [19335]: ERROR: Failed to resolve 'raw.githubusercontent.com'!
Wed Nov 18 17:31:40 2026 user.notice pbr [19335]: ERROR: Errors encountered, please check https://docs.openwrt.melmac.ca/pbr/1.2.2/#error-messages-details!
Suspected cause and locally tested fix
In cleanup(main_chains), PBR 1.2.2-r20 executes this directly against the live ruleset:
nft_call flush chain inet "$nftTable" "${i}"
With nftTable=fw4, nftPrefix=pbr and i=forward, the missing prefix targets fw4's general forward chain rather than PBR's own pbr_forward chain:
| Script expression | Actual chain |
|---|---|
${nftPrefix}_${i} |
pbr_forward (PBR-owned) |
${i} |
forward (fw4 base chain) |
The router's base chain has type filter hook forward priority filter; policy drop;. Flushing it removes the accept rules while retaining the drop policy, temporarily blocking forwarded traffic. PBR performs this cleanup before resolving domain policies and reloads fw4 only after policy processing. Thus the LAN resolver's upstream traffic can be blocked precisely while PBR needs fresh DNS answers.
Expected behaviour: cleanup should target PBR-owned chains and preserve fw4's unrelated forwarding rules.
This one-line change fixed the observed problem locally:
- nft_call flush chain inet "$nftTable" "${i}"
+ nft_call flush chain inet "$nftTable" "${nftPrefix}_${i}"
Affected code: net/pbr/files/etc/init.d/pbr, cleanup(main_chains).
Validation
After clearing the OpenWrt, Pi-hole and Unbound caches, fresh A lookups for ifconfig.co, github.com and raw.githubusercontent.com received matching upstream replies through tun0 in about 24 ms during policy processing. Extended testing through the following day remained error-free.
The tcpdump excerpts below support the diagnosis together with the code path and base-chain drop policy. They are not an nftables trace identifying a specific drop verdict.
Selected tcpdump evidence before and after the fix
These are excerpts of our domain-filtered, human-readable tcpdump output. Labels are translated to English and DNS server addresses omitted; timestamps, DNS IDs, ports and interface directions are retained.
Before the fix — Pi-hole: The same A query reappeared about 2.5 seconds later at both resolver hops. No successful reply is shown in this excerpt; these lines alone do not identify the point of failure.
2026-11-18 20:02:15.247181 | ifconfig.co A | OpenWrt -> Pi-hole | REQUEST | id=23060 port=33778
2026-11-18 20:02:15.247399 | ifconfig.co A | Pi-hole -> Unbound | REQUEST | id=13320 port=44609
2026-11-18 20:02:17.750166 | ifconfig.co A | OpenWrt -> Pi-hole | REQUEST | id=23060 port=33778
2026-11-18 20:02:17.750369 | ifconfig.co A | Pi-hole -> Unbound | REQUEST | id=13320 port=44609
Before the fix — OpenWrt, a separate failure window: An upstream query arrived on LAN interfaces. No matching tun0 output or reply was observed in that failure excerpt. Combined with the code path flushing forward before policy resolution and its retained policy drop, this supports the forwarding-blockage diagnosis.
2026-11-18 19:55:50.587947 | ifconfig.co A | LAN/Router -> VPN-DNS | REQUEST | id=16747 port=40740 | iface=eth0 dir=In source=Pi-hole-LAN destination=VPN-DNS
2026-11-18 19:55:50.587947 | ifconfig.co A | LAN/Router -> VPN-DNS | REQUEST | id=16747 port=40740 | iface=br-lan dir=In source=Pi-hole-LAN destination=VPN-DNS
After the fix — OpenWrt, fresh A lookup during policy processing: The query left through tun0; its matching NOERROR reply arrived about 24 ms later and was forwarded back to Pi-hole.
2026-11-18 21:12:01.795067 | ifconfig.co A | LAN/Router -> VPN-DNS | REQUEST | id=47141 port=25264 | iface=br-lan dir=In source=Pi-hole-LAN destination=VPN-DNS
2026-11-18 21:12:01.795144 | ifconfig.co A | LAN/Router -> VPN-DNS | REQUEST | id=47141 port=25264 | iface=tun0 dir=Out source=other-IP destination=VPN-DNS
2026-11-18 21:12:01.818940 | ifconfig.co A | VPN-DNS -> LAN/Router | RESPONSE NOERROR | id=47141 port=25264 | records=2/0/1 | iface=tun0 dir=In source=VPN-DNS destination=other-IP
2026-11-18 21:12:01.818994 | ifconfig.co A | VPN-DNS -> LAN/Router | RESPONSE NOERROR | id=47141 port=25264 | records=2/0/1 | iface=br-lan dir=Out source=VPN-DNS destination=Pi-hole-LAN
Next-day checks: Pi-hole received an A answer from Unbound; in a separate router capture, a DNS HTTPS query and its reply traversed tun0. These are different queries at different times, not one combined transaction. HTTPS here is a DNS record type, not the A-record policy-resolution test above.
2026-11-19 13:58:25.769280 | ifconfig.co A | Pi-hole -> Unbound | REQUEST | id=57856 port=47374
2026-11-19 13:58:25.817993 | ifconfig.co A | Unbound -> Pi-hole | RESPONSE NOERROR | id=57856 port=47374 | records=2/0/1
2026-11-19 20:15:31.908774 | ifconfig.co HTTPS | LAN/Router -> VPN-DNS | REQUEST | id=48338 port=42077 | iface=tun0 dir=Out source=other-IP destination=VPN-DNS
2026-11-19 20:15:31.937429 | ifconfig.co HTTPS | VPN-DNS -> LAN/Router | RESPONSE NOERROR | id=48338 port=42077 | records=1/0/1 | iface=tun0 dir=In source=VPN-DNS destination=other-IP
Capturing on any can show the same packet on both eth0 and br-lan. Such near-simultaneous observations are not counted as separate DNS retries; the seconds-apart repetitions above are the relevant distinction.
Additional package check
The candidate change was also packaged successfully using the official OpenWrt 25.12.5 x86/64 SDK in Debian 13 / WSL 2: make -j2 package/pbr/compile NO_DEPS=1 V=s (shell-only package; dependency rebuilds skipped). The resulting r21 APK passed integrity and packaged-script checks. Runtime tests used the same init-script fix in installed r20, not the new APK. No new APK was installed on the router.
LLM disclosure: An LLM assisted with diagnosis, the candidate code change, log selection/translation and drafting this report. Runtime tests were performed by me on my router.
Confirmation Checklist
- The package is maintained in this repository.
- I understand that issues related to the base OpenWrt repository or LuCI repository will be closed.
- I am reporting an issue for OpenWrt, not an unsupported fork.
- Dominant language
- Makefile
- Stars
- 4.7k
- Forks
- 4k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 287
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from openwrt/packages
-
release/25.12
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
ser2net: support 'host' option in ser2net_proxy() to allow binding to a specific IP (e.g. 127.0.0.1)Openbug release/25.12
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
bug release/25.12
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
openwrt/packages#31310 · 1 comment ·
Maintainers usually reply within 1 day
-
bug release/25.12
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
openwrt/packages#31309 · 1 comment ·
Maintainers usually reply within 1 day
-
bug release/25.12
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
openwrt/packages#31308 · 1 comment ·
Maintainers usually reply within 1 day
All issues in openwrt/packages
Similar issues
-
[Client] The `202 Accepted` that XRootD 6 sends to start a third-party copy is treated as a failurePossibly taken @Xnadir claimed this today. Openbug client
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
PelicanPlatform/pelican#3984 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Reconnect reads can use a light’s old network address after re-pairingPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Koenkk/zigbee2mqtt#33759 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
fabriziosalmi/blacklists#79 ·
Maintainers usually reply within 1 day