[GH-ISSUE #3314] macOS: site-based split tunneling is not applied for AWG/WireGuard — always full tunnel #3172

Open
opened 2026-10-25 04:14:52 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @DmStepankov on GitHub (Oct 22, 2026).
Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/3314

macOS: Site-based split tunneling is not applied for AWG/WireGuard — always full tunnel

Environment

  • AmneziaVPN client: 5.0.3.0 (macOS pkg, universal)
  • OS: macOS 27.0.1 (Apple Silicon, arm64)
  • Protocol: AWG (self-hosted server, amneziawg-tools v3.1.20260812)
  • GUI state: Settings → Split tunneling → Sites → "Only for selected sites" (Conf.routeMode = 1, Conf.ForwardSites populated with 36 domains), VPN reconnected after the change

Summary

On macOS, for AWG (and WireGuard) connections, the site-based split tunneling settings are silently ignored — the connection is always full tunnel. Two independent code paths cause this:

1. Route-split logic is skipped for AWG/WG containers

client/vpnConnection.cpp (VpnConnection::onConnectionStateChanged, Connected branch) wraps the entire split-tunneling route logic in:

// line 135
if (!ContainerUtils::isAwgContainer(container) && container != DockerContainer::WireGuard) {
    ...
    if (m_appSettingsRepository->isSitesSplitTunnelingEnabled()) {
        // routeDeleteList("0.0.0.0"), VpnOnlyForwardSites -> addSitesRoutes(),
        // VpnAllExceptSites -> 0.0.0.0/1 + 128.0.0.0/1 ...
    }
}

For AWG and WireGuard containers none of this ever runs: neither forward-site routes (include mode) nor exception routes (exclude mode) are added, and the DNS servers are not excluded from the tunnel on macOS.

2. Client config is hardcoded to full tunnel

client/core/configurators/wireguardConfigurator.cpp (line 275):

clientConfig.allowedIps = QStringList { "0.0.0.0/0", "::/0" };

This is unconditional — the configured split-tunneling mode is not reflected in AllowedIPs. The macOS daemon then expands the default route into two halves (client/platforms/macos/daemon/wireguardutilsmacos.cpp, updateRoutePrefix, line 357):

return m_rtmonitor->insertRoute(IPAddress("0.0.0.0/1")) &&
       m_rtmonitor->insertRoute(IPAddress("128.0.0.0/1"));

So every AWG connection gets 0/1 + 128.0/1 → tunnel, i.e. full tunnel, regardless of GUI state.

VpnProtocol::routeGateway() is only populated by the OpenVPN (openVpnProtocol.cpp:172,178) and Xray (xrayProtocol.cpp:33) protocols. For WireGuard/AWG it stays empty. The macOS-only branch in the VpnAllExceptSites path relies on it:

#ifdef Q_OS_MACOS
    iface->routeAddList(m_vpnProtocol->routeGateway(), QStringList() << dns1 << dns2);
#endif
    addSitesRoutes(m_vpnProtocol->routeGateway(), routeMode);

— so even for protocols where the split logic runs, on macOS the DNS exclusion routes and site routes are added via an empty gateway whenever the protocol is WG/AWG (routeAddList("", ip) silently fails).

Steps to reproduce

  1. macOS 27.0.1 (arm64), AmneziaVPN 5.0.3.0, self-hosted AWG server
  2. Settings → Split tunneling → Sites → mode "Only for selected sites", add e.g. youtube.com
  3. Connect via AWG
  4. route -n get alfabank.ru (not in the list) → interface: utunX (tunnel) — expected en0
  5. route -n get youtube.com → interface: utunX — this one is correct, but only because everything is routed into the tunnel

Actual result

  • route -n get default → en0, but 0/1 + 128.0/1 → utun (full tunnel in practice)
  • Sites not in the forward list (including the configured DNS servers, e.g. 1.1.1.1) are routed through the tunnel
  • GUI split-tunneling settings have no effect on AWG connections

Impact

  • "All except sites" mode cannot keep RU-local resources (banks, gov services) on the direct path — they egress via the VPN IP
  • Overlay VPNs that must coexist with Amnezia (e.g. Tailscale system extension) break under the captured routes: their control-plane sockets and UDP (STUN/DERP) die, tailscale netcheck reports UDP: false, controlplane unreachable — while ordinary user processes through the tunnel work fine
  • Workaround today: switch the connection to XRay (the same gate at vpnConnection.cpp:135 passes for it, so site-based split tunneling actually applies on macOS)

Expected result

Split tunneling (both "only selected sites" and "all except selected sites") should be honored for AWG/WireGuard connections on macOS — either by wiring the site lists into the daemon's exclusion/forward route handling (Daemon::addExclusionRoute / m_excludedAddresses already exist) or by computing AllowedIPs from the site lists.

Tested against dev branch (commit as of 2026-10-22). Happy to provide additional traces (route tables, netcheck output) if needed.

Originally created by @DmStepankov on GitHub (Oct 22, 2026). Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/3314 # macOS: Site-based split tunneling is not applied for AWG/WireGuard — always full tunnel ## Environment - AmneziaVPN client: **5.0.3.0** (macOS pkg, universal) - OS: **macOS 27.0.1** (Apple Silicon, arm64) - Protocol: **AWG** (self-hosted server, amneziawg-tools v3.1.20260812) - GUI state: Settings → Split tunneling → Sites → **"Only for selected sites"** (`Conf.routeMode = 1`, `Conf.ForwardSites` populated with 36 domains), VPN reconnected after the change ## Summary On macOS, for AWG (and WireGuard) connections, the site-based split tunneling settings are **silently ignored** — the connection is always full tunnel. Two independent code paths cause this: ### 1. Route-split logic is skipped for AWG/WG containers `client/vpnConnection.cpp` (`VpnConnection::onConnectionStateChanged`, Connected branch) wraps the **entire** split-tunneling route logic in: ```cpp // line 135 if (!ContainerUtils::isAwgContainer(container) && container != DockerContainer::WireGuard) { ... if (m_appSettingsRepository->isSitesSplitTunnelingEnabled()) { // routeDeleteList("0.0.0.0"), VpnOnlyForwardSites -> addSitesRoutes(), // VpnAllExceptSites -> 0.0.0.0/1 + 128.0.0.0/1 ... } } ``` For AWG and WireGuard containers none of this ever runs: neither forward-site routes (include mode) nor exception routes (exclude mode) are added, and the DNS servers are not excluded from the tunnel on macOS. ### 2. Client config is hardcoded to full tunnel `client/core/configurators/wireguardConfigurator.cpp` (line 275): ```cpp clientConfig.allowedIps = QStringList { "0.0.0.0/0", "::/0" }; ``` This is unconditional — the configured split-tunneling mode is not reflected in `AllowedIPs`. The macOS daemon then expands the default route into two halves (`client/platforms/macos/daemon/wireguardutilsmacos.cpp`, `updateRoutePrefix`, line 357): ```cpp return m_rtmonitor->insertRoute(IPAddress("0.0.0.0/1")) && m_rtmonitor->insertRoute(IPAddress("128.0.0.0/1")); ``` So every AWG connection gets `0/1` + `128.0/1` → tunnel, i.e. full tunnel, regardless of GUI state. ### 3. Related: `routeGateway()` is never set for WG/AWG `VpnProtocol::routeGateway()` is only populated by the OpenVPN (`openVpnProtocol.cpp:172,178`) and Xray (`xrayProtocol.cpp:33`) protocols. For WireGuard/AWG it stays empty. The macOS-only branch in the `VpnAllExceptSites` path relies on it: ```cpp #ifdef Q_OS_MACOS iface->routeAddList(m_vpnProtocol->routeGateway(), QStringList() << dns1 << dns2); #endif addSitesRoutes(m_vpnProtocol->routeGateway(), routeMode); ``` — so even for protocols where the split logic runs, on macOS the DNS exclusion routes and site routes are added via an **empty gateway** whenever the protocol is WG/AWG (`routeAddList("", ip)` silently fails). ## Steps to reproduce 1. macOS 27.0.1 (arm64), AmneziaVPN 5.0.3.0, self-hosted AWG server 2. Settings → Split tunneling → Sites → mode "Only for selected sites", add e.g. `youtube.com` 3. Connect via AWG 4. `route -n get alfabank.ru` (not in the list) → `interface: utunX` (tunnel) — expected `en0` 5. `route -n get youtube.com` → `interface: utunX` — this one is correct, but only because everything is routed into the tunnel ## Actual result - `route -n get default` → en0, but `0/1` + `128.0/1` → utun (full tunnel in practice) - Sites **not** in the forward list (including the configured DNS servers, e.g. 1.1.1.1) are routed through the tunnel - GUI split-tunneling settings have **no effect** on AWG connections ## Impact - "All except sites" mode cannot keep RU-local resources (banks, gov services) on the direct path — they egress via the VPN IP - Overlay VPNs that must coexist with Amnezia (e.g. Tailscale system extension) break under the captured routes: their control-plane sockets and UDP (STUN/DERP) die, `tailscale netcheck` reports `UDP: false`, controlplane unreachable — while ordinary user processes through the tunnel work fine - Workaround today: switch the connection to XRay (the same gate at `vpnConnection.cpp:135` passes for it, so site-based split tunneling actually applies on macOS) ## Expected result Split tunneling (both "only selected sites" and "all except selected sites") should be honored for AWG/WireGuard connections on macOS — either by wiring the site lists into the daemon's exclusion/forward route handling (`Daemon::addExclusionRoute` / `m_excludedAddresses` already exist) or by computing `AllowedIPs` from the site lists. Tested against dev branch (commit as of 2026-10-22). Happy to provide additional traces (route tables, netcheck output) if needed.
Author
Owner

@igorburago commented on GitHub (Oct 24, 2026):

Just ran into this very bug myself. Can confirm both the erroneous behavior and its culprit in the code.

<!-- gh-comment-id:6381415149 --> @igorburago commented on GitHub (Oct 24, 2026): Just ran into this very bug myself. Can confirm both the erroneous behavior and its culprit in the code.
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#3172
No description provided.