[PR #2292] fix(macos): prevent pf firewall from blocking IPv6 VPN traffic #2751

Open
opened 2026-10-15 04:04:30 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/amnezia-vpn/amnezia-client/pull/2292
Author: @intexcor
Created: 2/27/2026
Status: 🔄 Open

Base: dev ← Head: fix/macos-pf-ipv6-block-vpn-traffic


📝 Commits (2)

  • 42536b5 fix(macos): prevent pf firewall from blocking IPv6 VPN traffic
  • 71ceb26 Merge branch 'amnezia-vpn:dev' into fix/macos-pf-ipv6-block-vpn-traffic

📊 Changes

3 files changed (+19 additions, -3 deletions)

View changed files

📝 client/platforms/macos/daemon/wireguardutilsmacos.cpp (+15 -1)
📝 deploy/data/macos/pf/amn.200.allowVPN.conf (+1 -1)
📝 deploy/data/macos/pf/amn.250.blockIPv6.conf (+3 -1)

📄 Description

Summary

  • Add quick keyword to pf anchor 200.allowVPN so VPN tunnel traffic is immediately passed without evaluating later anchors
  • Make 250.blockIPv6 anchor conditional — only enabled when AllowedIPs contains no IPv6 ranges
  • Update comment in 250.blockIPv6.conf to reflect actual behavior

Root cause

In macOS pf, rules are evaluated last-match-wins (unless quick). The anchor 200.allowVPN passes all traffic on utun interfaces, but the later anchor 250.blockIPv6 blocks all outgoing IPv6 — including IPv6 packets inside the VPN tunnel. This causes:

  1. Chrome/QUIC tries IPv6 first (Happy Eyeballs) → blocked by pf → timeout
  2. Fallback to IPv4 is slow or fails entirely → ERR_SOCKET_NOT_CONNECTED

Adding quick to rule 200 makes it a terminal match — VPN tunnel traffic is passed immediately, and rule 250 never sees it.

Additionally, when the VPN routes IPv6 (e.g. AllowedIPs includes ::/0), blocking IPv6 outside the tunnel is unnecessary since all IPv6 goes through the tunnel anyway. The code now checks AllowedIPs and only enables 250.blockIPv6 when there are no IPv6 routes.

Test plan

  • Verified with pfctl -vnf that the quick rule parses correctly
  • Applied fix to running pf rules via pfctl -a — confirmed traffic flows correctly
  • Tested Chrome, Zoom with AmneziaWG VPN active — no more ERR_SOCKET_NOT_CONNECTED

Fixes #945


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/amnezia-vpn/amnezia-client/pull/2292 **Author:** [@intexcor](https://github.com/intexcor) **Created:** 2/27/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `fix/macos-pf-ipv6-block-vpn-traffic` --- ### 📝 Commits (2) - [`42536b5`](https://github.com/amnezia-vpn/amnezia-client/commit/42536b5dfb71e307a6ad04f9420b881ecb608446) fix(macos): prevent pf firewall from blocking IPv6 VPN traffic - [`71ceb26`](https://github.com/amnezia-vpn/amnezia-client/commit/71ceb26cc24654aff584d221cbb3fcc70afd3bd5) Merge branch 'amnezia-vpn:dev' into fix/macos-pf-ipv6-block-vpn-traffic ### 📊 Changes **3 files changed** (+19 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `client/platforms/macos/daemon/wireguardutilsmacos.cpp` (+15 -1) 📝 `deploy/data/macos/pf/amn.200.allowVPN.conf` (+1 -1) 📝 `deploy/data/macos/pf/amn.250.blockIPv6.conf` (+3 -1) </details> ### 📄 Description ## Summary - Add `quick` keyword to pf anchor `200.allowVPN` so VPN tunnel traffic is immediately passed without evaluating later anchors - Make `250.blockIPv6` anchor conditional — only enabled when `AllowedIPs` contains no IPv6 ranges - Update comment in `250.blockIPv6.conf` to reflect actual behavior ## Root cause In macOS pf, rules are evaluated last-match-wins (unless `quick`). The anchor `200.allowVPN` passes all traffic on utun interfaces, but the later anchor `250.blockIPv6` blocks **all** outgoing IPv6 — including IPv6 packets inside the VPN tunnel. This causes: 1. Chrome/QUIC tries IPv6 first (Happy Eyeballs) → blocked by pf → timeout 2. Fallback to IPv4 is slow or fails entirely → `ERR_SOCKET_NOT_CONNECTED` Adding `quick` to rule 200 makes it a terminal match — VPN tunnel traffic is passed immediately, and rule 250 never sees it. Additionally, when the VPN routes IPv6 (e.g. `AllowedIPs` includes `::/0`), blocking IPv6 outside the tunnel is unnecessary since all IPv6 goes through the tunnel anyway. The code now checks `AllowedIPs` and only enables `250.blockIPv6` when there are no IPv6 routes. ## Test plan - [x] Verified with `pfctl -vnf` that the `quick` rule parses correctly - [x] Applied fix to running pf rules via `pfctl -a` — confirmed traffic flows correctly - [x] Tested Chrome, Zoom with AmneziaWG VPN active — no more `ERR_SOCKET_NOT_CONNECTED` Fixes #945 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/amnezia-client#2751
No description provided.