[GH-ISSUE #3110] Linux: NetworkManager CONNECTED_GLOBAL transition causes unnecessary full VPN reconnect #1442

Open
opened 2026-10-14 03:42:34 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @smollgreymouse on GitHub (Sep 1, 2026).
Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/3110

Linux: NetworkManager CONNECTED_GLOBAL transition causes unnecessary full VPN reconnect and recreates tun2

Describe the bug

On Linux, AmneziaVPN performs a full VPN reconnect whenever NetworkManager emits:

StateChanged(NM_STATE_CONNECTED_GLOBAL = 70)

even when the physical network, Wi-Fi access point, interface, and gateway have not actually changed.

A normal NetworkManager connectivity transition:

CONNECTED_GLOBAL -> CONNECTED_SITE -> CONNECTED_GLOBAL

is interpreted by AmneziaVPN as a network change.

When NetworkManager returns to CONNECTED_GLOBAL, AmneziaVPN calls VpnConnection::reconnectToVpn(). With Xray this stops Xray/tun2socks, destroys tun2, and creates a new tunnel.

In my case the event is triggered periodically by NetworkManager connectivity checks. The Wi-Fi access point does not change.

The unnecessary reconnect is disruptive by itself, but the reconnect cleanup also sometimes fails, leaving DNS/routes in a broken state until a manual VPN reconnect.

Environment

  • OS: Ubuntu 25.10
  • Kernel: Linux 6.17.0-41-generic
  • Network manager: NetworkManager
  • VPN protocol: Xray
  • Xray data path: tun2 + tun2socks
  • TUN address: 10.33.0.2/24
  • Physical connection remains active during the reproduced event

Reproduced timeline

Incident captured on 2026-08-31.

NetworkManager changes connectivity classification

16:30:05.947  DNS query: connectivity-check.ubuntu.com A
16:30:06.312  DNS reply: NOERROR
16:30:06.628  NetworkManager state is now CONNECTED_SITE
16:30:06.xxx  Amnezia LinuxNetworkWatcherWorker: NMStateChanged 60

NetworkManager then retries connectivity checks.

Approximately 31 seconds later:

16:30:37.338  DNS reply: NOERROR
16:30:37.657  NetworkManager state is now CONNECTED_GLOBAL
16:30:37.658  Amnezia LinuxNetworkWatcherWorker:
               Properties changed for interface org.freedesktop.NetworkManager.Device
16:30:37.658  Amnezia LinuxNetworkWatcherWorker:
               Access point did not changed. Ignoring the changes
16:30:37.658  Amnezia LinuxNetworkWatcherWorker:
               NMStateChanged 70

The important part is that AmneziaVPN itself reports that the access point did not change.

AmneziaVPN immediately reconnects

Immediately after NMStateChanged 70:

AmneziaVPN.desktop:
Reconnect triggered. Reconnecting to the server

AmneziaVPN.desktop:
XrayProtocol::stop()

The existing TUN is then removed:

NetworkManager:
device (tun2): state change: activated -> unmanaged
(reason 'unmanaged', managed-type: 'removed')

AmneziaVPN-service:
deleteTun ret 0

The diagnostic bundle independently confirms that the TUN FD was owned by Amnezia's tun2socks process.

Cleanup errors

During this automatic reconnect the logs also contain:

Failed to delete tun
No suitable DNS manager found.
VpnConnection::onConnectionStateChanged: Failed to flush DNS
Failed to clear saved routes

and several route deletion failures.

A pkill invocation also reports:

pkill: pattern that searches for process name longer than 15 characters
will result in zero matches
Try `pkill -f' ...

Tunnel is recreated

AmneziaVPN then starts Xray/tun2socks again and creates a new TUN:

XrayProtocol::start()
Xray::startXray()

tun2socks -device tun://tun2 -proxy socks5://127.0.0.1:...

ip tuntap add mode tun dev tun2
ip addr add 10.33.0.2/24 dev tun2
ip link set dev tun2 up

Therefore the tun2 deletion is not caused by NetworkManager. NetworkManager observes the externally managed interface disappearing.

The tunnel is deliberately torn down by AmneziaVPN as part of reconnectToVpn().

Source-code cause

Current Linux code in:

client/platforms/linux/linuxnetworkwatcherworker.cpp

contains:

void LinuxNetworkWatcherWorker::NMStateChanged(quint32 state)
{
    logger.debug() << "NMStateChanged " << state;

    if (state == NM_STATE_ASLEEP || state == NM_STATE_DISABLED) {
        emit wakeup();
    } else if (state == NM_STATE_CONNECTED_GLOBAL) {
        emit networkChanged();
    }
}

Therefore every NetworkManager transition to CONNECTED_GLOBAL becomes networkChanged().

LinuxNetworkWatcher forwards it:

connect(m_worker, &LinuxNetworkWatcherWorker::networkChanged, this,
        [this]() { emit networkChanged(""); });

The service exposes it through IPC:

connect(&m_networkWatcher, &NetworkWatcher::networkChanged,
        &m_ipcServer, &IpcServer::networkChanged);

and VpnConnection connects that directly to:

VpnConnection::reconnectToVpn

reconnectToVpn() performs:

qDebug() << "Reconnect triggered. Reconnecting to the server";

setConnectionState(Vpn::ConnectionState::Reconnecting);

m_vpnProtocol->stop();
m_vpnProtocol->start();

The effective Linux behavior is therefore:

NetworkManager CONNECTED_GLOBAL
        ↓
networkChanged()
        ↓
VpnConnection::reconnectToVpn()
        ↓
stop VPN
        ↓
destroy tun2
        ↓
start VPN
        ↓
create new tun2

But CONNECTED_GLOBAL is a NetworkManager connectivity classification, not proof that the underlying network changed.

Regression history

This behavior appears to have been introduced by:

PR #2415:

https://github.com/amnezia-vpn/amnezia-client/pull/2415

Commit:

ebe3a5dac6ae7101cb7e9520903ce92a0d1ed32e
fix: add linux reconnection (#2415)

That change added:

else if (state == NM_STATE_CONNECTED_GLOBAL) {
    emit networkChanged();
}

There is also relevant earlier history.

Commit:

911a999c64b1bf107645cd4c5b1f4eee372c3914

contained:

fix: remove network watcher due to its fragileness

The watcher was subsequently restored and Linux reconnection behavior was added again.

Why this is not a real network change

At the exact triggering timestamp AmneziaVPN logs:

Access point did not changed. Ignoring the changes
NMStateChanged 70

Therefore Amnezia's own AP detection says that the Wi-Fi network did not change.

The only relevant change is NetworkManager's global connectivity state returning from:

CONNECTED_SITE

to:

CONNECTED_GLOBAL

Periodic connectivity-check.ubuntu.com checks are visible immediately around these transitions.

Even if NetworkManager is completely correct to change its connectivity classification, AmneziaVPN should not equate every transition to CONNECTED_GLOBAL with a physical network change.

Expected behavior

A pure connectivity-classification transition:

CONNECTED_SITE -> CONNECTED_GLOBAL

must not cause a full VPN reconnect by itself.

Reconnect should happen when there is evidence of a real underlying-network change, for example:

  • physical interface changed;
  • active NetworkManager connection changed;
  • Wi-Fi AP/BSSID changed;
  • default gateway changed;
  • system resumed from suspend;
  • previous physical connection disappeared;
  • VPN data plane actually failed.

NetworkManager Internet-connectivity classification should not be used as a substitute for these checks.

Suggested fix

Please do not use:

state == NM_STATE_CONNECTED_GLOBAL

by itself as the condition for networkChanged().

A robust implementation could compare a physical-network identity tuple before reconnecting, for example:

physical interface
active connection
gateway
Wi-Fi BSSID where applicable

and emit networkChanged() only when that identity actually changes.

Alternatively, listen to NetworkManager active-connection/device changes rather than its global Internet-connectivity classification.

Wakeup handling should remain separate.

It would also be useful to debounce/deduplicate reconnect events while the connection is already reconnecting.

Additional problem exposed by the unnecessary reconnect

The automatic reconnect frequently reports cleanup failures:

Failed to flush DNS
Failed to clear saved routes
Failed to delete tun

This can leave the newly created tunnel in a partially broken state even though the application reports it as connected.

A manual Disconnect -> Connect can restore connectivity.

So eliminating false reconnects would prevent the immediate trigger, while cleanup/reconnect reliability should probably be investigated separately as well.

Originally created by @smollgreymouse on GitHub (Sep 1, 2026). Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/3110 # Linux: NetworkManager CONNECTED_GLOBAL transition causes unnecessary full VPN reconnect and recreates tun2 ## Describe the bug On Linux, AmneziaVPN performs a full VPN reconnect whenever NetworkManager emits: ```text StateChanged(NM_STATE_CONNECTED_GLOBAL = 70) ``` even when the physical network, Wi-Fi access point, interface, and gateway have not actually changed. A normal NetworkManager connectivity transition: ```text CONNECTED_GLOBAL -> CONNECTED_SITE -> CONNECTED_GLOBAL ``` is interpreted by AmneziaVPN as a network change. When NetworkManager returns to `CONNECTED_GLOBAL`, AmneziaVPN calls `VpnConnection::reconnectToVpn()`. With Xray this stops Xray/tun2socks, destroys `tun2`, and creates a new tunnel. In my case the event is triggered periodically by NetworkManager connectivity checks. The Wi-Fi access point does not change. The unnecessary reconnect is disruptive by itself, but the reconnect cleanup also sometimes fails, leaving DNS/routes in a broken state until a manual VPN reconnect. ## Environment * OS: Ubuntu 25.10 * Kernel: Linux 6.17.0-41-generic * Network manager: NetworkManager * VPN protocol: Xray * Xray data path: `tun2` + `tun2socks` * TUN address: `10.33.0.2/24` * Physical connection remains active during the reproduced event ## Reproduced timeline Incident captured on 2026-08-31. ### NetworkManager changes connectivity classification ```text 16:30:05.947 DNS query: connectivity-check.ubuntu.com A 16:30:06.312 DNS reply: NOERROR 16:30:06.628 NetworkManager state is now CONNECTED_SITE 16:30:06.xxx Amnezia LinuxNetworkWatcherWorker: NMStateChanged 60 ``` NetworkManager then retries connectivity checks. Approximately 31 seconds later: ```text 16:30:37.338 DNS reply: NOERROR 16:30:37.657 NetworkManager state is now CONNECTED_GLOBAL 16:30:37.658 Amnezia LinuxNetworkWatcherWorker: Properties changed for interface org.freedesktop.NetworkManager.Device 16:30:37.658 Amnezia LinuxNetworkWatcherWorker: Access point did not changed. Ignoring the changes 16:30:37.658 Amnezia LinuxNetworkWatcherWorker: NMStateChanged 70 ``` The important part is that AmneziaVPN itself reports that the access point did not change. ### AmneziaVPN immediately reconnects Immediately after `NMStateChanged 70`: ```text AmneziaVPN.desktop: Reconnect triggered. Reconnecting to the server AmneziaVPN.desktop: XrayProtocol::stop() ``` The existing TUN is then removed: ```text NetworkManager: device (tun2): state change: activated -> unmanaged (reason 'unmanaged', managed-type: 'removed') AmneziaVPN-service: deleteTun ret 0 ``` The diagnostic bundle independently confirms that the TUN FD was owned by Amnezia's `tun2socks` process. ### Cleanup errors During this automatic reconnect the logs also contain: ```text Failed to delete tun No suitable DNS manager found. VpnConnection::onConnectionStateChanged: Failed to flush DNS Failed to clear saved routes ``` and several route deletion failures. A `pkill` invocation also reports: ```text pkill: pattern that searches for process name longer than 15 characters will result in zero matches Try `pkill -f' ... ``` ### Tunnel is recreated AmneziaVPN then starts Xray/tun2socks again and creates a new TUN: ```text XrayProtocol::start() Xray::startXray() tun2socks -device tun://tun2 -proxy socks5://127.0.0.1:... ip tuntap add mode tun dev tun2 ip addr add 10.33.0.2/24 dev tun2 ip link set dev tun2 up ``` Therefore the `tun2` deletion is not caused by NetworkManager. NetworkManager observes the externally managed interface disappearing. The tunnel is deliberately torn down by AmneziaVPN as part of `reconnectToVpn()`. ## Source-code cause Current Linux code in: ```text client/platforms/linux/linuxnetworkwatcherworker.cpp ``` contains: ```cpp void LinuxNetworkWatcherWorker::NMStateChanged(quint32 state) { logger.debug() << "NMStateChanged " << state; if (state == NM_STATE_ASLEEP || state == NM_STATE_DISABLED) { emit wakeup(); } else if (state == NM_STATE_CONNECTED_GLOBAL) { emit networkChanged(); } } ``` Therefore every NetworkManager transition to `CONNECTED_GLOBAL` becomes `networkChanged()`. `LinuxNetworkWatcher` forwards it: ```cpp connect(m_worker, &LinuxNetworkWatcherWorker::networkChanged, this, [this]() { emit networkChanged(""); }); ``` The service exposes it through IPC: ```cpp connect(&m_networkWatcher, &NetworkWatcher::networkChanged, &m_ipcServer, &IpcServer::networkChanged); ``` and `VpnConnection` connects that directly to: ```cpp VpnConnection::reconnectToVpn ``` `reconnectToVpn()` performs: ```cpp qDebug() << "Reconnect triggered. Reconnecting to the server"; setConnectionState(Vpn::ConnectionState::Reconnecting); m_vpnProtocol->stop(); m_vpnProtocol->start(); ``` The effective Linux behavior is therefore: ```text NetworkManager CONNECTED_GLOBAL ↓ networkChanged() ↓ VpnConnection::reconnectToVpn() ↓ stop VPN ↓ destroy tun2 ↓ start VPN ↓ create new tun2 ``` But `CONNECTED_GLOBAL` is a NetworkManager connectivity classification, not proof that the underlying network changed. ## Regression history This behavior appears to have been introduced by: PR #2415: https://github.com/amnezia-vpn/amnezia-client/pull/2415 Commit: ```text ebe3a5dac6ae7101cb7e9520903ce92a0d1ed32e fix: add linux reconnection (#2415) ``` That change added: ```cpp else if (state == NM_STATE_CONNECTED_GLOBAL) { emit networkChanged(); } ``` There is also relevant earlier history. Commit: ```text 911a999c64b1bf107645cd4c5b1f4eee372c3914 ``` contained: ```text fix: remove network watcher due to its fragileness ``` The watcher was subsequently restored and Linux reconnection behavior was added again. ## Why this is not a real network change At the exact triggering timestamp AmneziaVPN logs: ```text Access point did not changed. Ignoring the changes NMStateChanged 70 ``` Therefore Amnezia's own AP detection says that the Wi-Fi network did not change. The only relevant change is NetworkManager's global connectivity state returning from: ```text CONNECTED_SITE ``` to: ```text CONNECTED_GLOBAL ``` Periodic `connectivity-check.ubuntu.com` checks are visible immediately around these transitions. Even if NetworkManager is completely correct to change its connectivity classification, AmneziaVPN should not equate every transition to `CONNECTED_GLOBAL` with a physical network change. ## Expected behavior A pure connectivity-classification transition: ```text CONNECTED_SITE -> CONNECTED_GLOBAL ``` must not cause a full VPN reconnect by itself. Reconnect should happen when there is evidence of a real underlying-network change, for example: * physical interface changed; * active NetworkManager connection changed; * Wi-Fi AP/BSSID changed; * default gateway changed; * system resumed from suspend; * previous physical connection disappeared; * VPN data plane actually failed. NetworkManager Internet-connectivity classification should not be used as a substitute for these checks. ## Suggested fix Please do not use: ```cpp state == NM_STATE_CONNECTED_GLOBAL ``` by itself as the condition for `networkChanged()`. A robust implementation could compare a physical-network identity tuple before reconnecting, for example: ```text physical interface active connection gateway Wi-Fi BSSID where applicable ``` and emit `networkChanged()` only when that identity actually changes. Alternatively, listen to NetworkManager active-connection/device changes rather than its global Internet-connectivity classification. Wakeup handling should remain separate. It would also be useful to debounce/deduplicate reconnect events while the connection is already reconnecting. ## Additional problem exposed by the unnecessary reconnect The automatic reconnect frequently reports cleanup failures: ```text Failed to flush DNS Failed to clear saved routes Failed to delete tun ``` This can leave the newly created tunnel in a partially broken state even though the application reports it as connected. A manual Disconnect -> Connect can restore connectivity. So eliminating false reconnects would prevent the immediate trigger, while cleanup/reconnect reliability should probably be investigated separately as well.
Author
Owner

@HeisLuka commented on GitHub (Sep 8, 2026):

I think the current Linux watcher has a second, symmetric problem in addition to the false-positive described here.

The current event mapping is approximately:

NetworkManager connectivity classification changed
-> NM_STATE_CONNECTED_GLOBAL
-> networkChanged()
-> reconnect

actual Wi-Fi identity changed
-> ActiveAccessPoint PropertiesChanged
-> checkDevices()
-> security check only
-> no networkChanged()

propertyChanged() explicitly notices ActiveAccessPoint, but then only calls checkDevices().

checkDevices() reads the active AP and its BSSID/SSID/security properties, but it only emits unsecuredNetwork(...); it never emits networkChanged().

The worker also keeps only:

QStringList m_devicePaths;

so it currently has no previous physical-network identity to compare against.

This gives a useful pair of deterministic countertests.

False positive — already reproduced in this issue

physical identity:
Wi-Fi AP A
interface wlan0
gateway G

NM state:
CONNECTED_SITE -> CONNECTED_GLOBAL

physical identity after:
still AP A / wlan0 / G

current:
networkChanged()
full reconnect

expected:
no reconnect caused only by connectivity classification

Mirror false negative

before:
ActiveAccessPoint = AP-A
NM state = CONNECTED_GLOBAL

after:
ActiveAccessPoint = AP-B
NM state remains CONNECTED_GLOBAL

current code path:
PropertiesChanged("ActiveAccessPoint")
-> checkDevices()
-> no networkChanged()

expected:
physical-path change is observed/reconciled

The second case does not require claiming that NetworkManager always emits exactly this event sequence; it is a code-level invariant test: an ActiveAccessPoint identity change by itself currently cannot produce the reconnect signal.

I would therefore separate two state dimensions:

physical_identity =
active connection
physical interface
default gateway
Wi-Fi BSSID where applicable

connectivity_health =
LOCAL / SITE / GLOBAL

and never use:

connectivity_health changed
== physical_identity changed

A possible state transition contract:

physical_identity old == new

  • SITE -> GLOBAL
    -> keep existing VPN dataplane

physical_identity old != new
-> reconcile/rebind/reconnect once

resume from suspend
-> wait until physical path is usable
-> obtain new identity
-> reconcile once

dataplane failure with unchanged identity
-> separate health/recovery path

This also matters for Ethernet/mobile/other non-Wi-Fi changes: initialize() currently subscribes device PropertiesChanged only for devices whose DeviceType == WIFI, while the global NetworkManager state is used as the generic reconnect trigger.

So I would prefer a platform-level PhysicalPathSnapshot, for example:

{
activeConnection,
interfaceIndex/name,
gateway,
wifiBssid optional
}

with:

previousSnapshot != newSnapshot
=> physicalPathChanged

and keep NetworkManager's connectivity classification as a separate signal.

There is also a suspend-related detail:

if (state == NM_STATE_ASLEEP || state == NM_STATE_DISABLED)
emit wakeup();

wakeup is connected to the same reconnectToVpn() path, so reconnect can currently be requested while NetworkManager is entering the asleep state.

That seems opposite to the intended recovery ordering described in #2684:

sleep
-> wait for physical network recovery
-> CONNECTED/usable path
-> reconnect once

rather than:

ASLEEP
-> reconnect immediately

One more note: VpnConnection::reconnectToVpn() already ignores reconnect events unless the state is Connected, so duplicate events during an active Reconnecting transition are already partially gated. I would fix the event semantics before adding another debounce layer.

Regression matrix I would use:

  1. same AP/interface/gateway, SITE -> GLOBAL
    reconnect count = 0

  2. AP-A -> AP-B, global connectivity remains available
    physical-path reconciliation count = 1

  3. Wi-Fi -> Ethernet
    reconciliation count = 1

  4. CONNECTED_GLOBAL repeated N times, identity unchanged
    reconnect count = 0

  5. enter ASLEEP
    reconnect count = 0

  6. resume, path becomes usable
    one controlled reconciliation

  7. burst of identity-related notifications for one transition
    at most one concurrent reconnect

I think this would fix both sides of the classifier:

health change != path identity change

instead of only suppressing this particular CONNECTED_SITE -> CONNECTED_GLOBAL reproduction.

<!-- gh-comment-id:5588128168 --> @HeisLuka commented on GitHub (Sep 8, 2026): I think the current Linux watcher has a second, symmetric problem in addition to the false-positive described here. The current event mapping is approximately: NetworkManager connectivity classification changed -> NM_STATE_CONNECTED_GLOBAL -> networkChanged() -> reconnect actual Wi-Fi identity changed -> ActiveAccessPoint PropertiesChanged -> checkDevices() -> security check only -> no networkChanged() propertyChanged() explicitly notices ActiveAccessPoint, but then only calls checkDevices(). checkDevices() reads the active AP and its BSSID/SSID/security properties, but it only emits unsecuredNetwork(...); it never emits networkChanged(). The worker also keeps only: QStringList m_devicePaths; so it currently has no previous physical-network identity to compare against. This gives a useful pair of deterministic countertests. False positive — already reproduced in this issue physical identity: Wi-Fi AP A interface wlan0 gateway G NM state: CONNECTED_SITE -> CONNECTED_GLOBAL physical identity after: still AP A / wlan0 / G current: networkChanged() full reconnect expected: no reconnect caused only by connectivity classification Mirror false negative before: ActiveAccessPoint = AP-A NM state = CONNECTED_GLOBAL after: ActiveAccessPoint = AP-B NM state remains CONNECTED_GLOBAL current code path: PropertiesChanged("ActiveAccessPoint") -> checkDevices() -> no networkChanged() expected: physical-path change is observed/reconciled The second case does not require claiming that NetworkManager always emits exactly this event sequence; it is a code-level invariant test: an ActiveAccessPoint identity change by itself currently cannot produce the reconnect signal. I would therefore separate two state dimensions: physical_identity = active connection physical interface default gateway Wi-Fi BSSID where applicable connectivity_health = LOCAL / SITE / GLOBAL and never use: connectivity_health changed == physical_identity changed A possible state transition contract: physical_identity old == new + SITE -> GLOBAL -> keep existing VPN dataplane physical_identity old != new -> reconcile/rebind/reconnect once resume from suspend -> wait until physical path is usable -> obtain new identity -> reconcile once dataplane failure with unchanged identity -> separate health/recovery path This also matters for Ethernet/mobile/other non-Wi-Fi changes: initialize() currently subscribes device PropertiesChanged only for devices whose DeviceType == WIFI, while the global NetworkManager state is used as the generic reconnect trigger. So I would prefer a platform-level PhysicalPathSnapshot, for example: { activeConnection, interfaceIndex/name, gateway, wifiBssid optional } with: previousSnapshot != newSnapshot => physicalPathChanged and keep NetworkManager's connectivity classification as a separate signal. There is also a suspend-related detail: if (state == NM_STATE_ASLEEP || state == NM_STATE_DISABLED) emit wakeup(); wakeup is connected to the same reconnectToVpn() path, so reconnect can currently be requested while NetworkManager is entering the asleep state. That seems opposite to the intended recovery ordering described in #2684: sleep -> wait for physical network recovery -> CONNECTED/usable path -> reconnect once rather than: ASLEEP -> reconnect immediately One more note: VpnConnection::reconnectToVpn() already ignores reconnect events unless the state is Connected, so duplicate events during an active Reconnecting transition are already partially gated. I would fix the event semantics before adding another debounce layer. Regression matrix I would use: 1. same AP/interface/gateway, SITE -> GLOBAL reconnect count = 0 2. AP-A -> AP-B, global connectivity remains available physical-path reconciliation count = 1 3. Wi-Fi -> Ethernet reconciliation count = 1 4. CONNECTED_GLOBAL repeated N times, identity unchanged reconnect count = 0 5. enter ASLEEP reconnect count = 0 6. resume, path becomes usable one controlled reconciliation 7. burst of identity-related notifications for one transition at most one concurrent reconnect I think this would fix both sides of the classifier: health change != path identity change instead of only suppressing this particular CONNECTED_SITE -> CONNECTED_GLOBAL reproduction.
Author
Owner

@firefoxic commented on GitHub (Sep 28, 2026):

Same root cause reproduced on a different protocol and with a second, deterministic trigger. Adding it here because it also explains a user-visible symptom that has no issue of its own.

Environment

  • Fedora Silverblue 44, kernel 7.2.7, NetworkManager 1.56.1, GNOME Shell 50
  • AmneziaVPN 5.0.3.0, self-hosted server, protocol AmneziaWG (userspace amneziawg-go, interface amn0)
  • Kill Switch enabled

Where the reconnect comes from

client/platforms/linux/linuxnetworkwatcherworker.cpp, LinuxNetworkWatcherWorker::NMStateChanged():

} else if (state == NM_STATE_CONNECTED_GLOBAL) {
    emit networkChanged();
}

Every StateChanged(70) is mapped to networkChanged() unconditionally, and VpnConnection connects that signal straight to reconnectToVpn(). Nothing compares the physical network before and after, so a pure connectivity reclassification by NetworkManager is enough to tear the tunnel down.

Why it is deterministic with Kill Switch on

NetworkManager's connectivity check is an HTTP request bound to each interface separately. With Kill Switch on, the request leaving the physical interface is rejected by the firewall (immediate Connection refused from the local address), so that interface is permanently limited. NetworkManager computes its global state only from devices with a default route it configured itself. amn0 is externally managed and carries 0.0.0.0/1 + 128.0.0.0/1 rather than 0.0.0.0/0, so it is not considered at all. Result: while the VPN is up, NetworkManager sits in CONNECTED_SITE (nmcli general shows limited / connected (site only)).

Any event that brings NetworkManager back to CONNECTED_GLOBAL now triggers a full reconnect. I hit it two ways:

  1. Giving amn0 a managed NetworkManager profile with a real default route (so the connectivity check on amn0 counts). The check returned full, NetworkManager announced CONNECTED_GLOBAL, and the client reconnected within 70 ms, destroying the very interface that had just been made to work. Repeating the step gives an infinite loop.
  2. Simply disabling NetworkManager's connectivity checking ([connectivity] enabled=false) while the VPN is connected. NetworkManager assumes full, goes to CONNECTED_GLOBAL, and the client reconnects once.

Log from case 1 (times are local):

11:14:03.174  NetworkManager: manager: NetworkManager state is now CONNECTED_GLOBAL
11:14:03.178  AmneziaVPN-service: LinuxNetworkWatcherWorker : NMStateChanged  70
11:14:03.241  AmneziaVPN.desktop: Reconnect triggered. Reconnecting to the server
11:14:03.243  AmneziaVPN-service: Daemon : Deleting routes for InterfaceConfig::SingleHop
11:14:03.376  NetworkManager: device (amn0): state change: activated -> unmanaged (reason 'unmanaged', managed-type: 'removed')
11:14:05.023  AmneziaVPN-service: WireguardUtilsLinux : Created wireguard interface amn0

No Wi‑Fi involved at all: wired ens9, same gateway, same interface before and after.

User-visible side effect

Because NetworkManager is stuck in CONNECTED_SITE whenever Kill Switch is on, GNOME Shell draws the "no route" network icon (the grey icon with a question mark) for the whole VPN session, and desktop apps that use GNetworkMonitor see limited connectivity. The only workarounds are disabling Kill Switch or disabling NetworkManager's connectivity check system-wide, and the latter also removes captive portal detection (related to #3106).

Suggested fix

  • Do not treat CONNECTED_SITE -> CONNECTED_GLOBAL (or CONNECTED_LOCAL -> CONNECTED_GLOBAL) as a network change. Only transitions from DISCONNECTED / CONNECTING into a connected state can mean a new network.
  • Better: track the physical identity (primary device path, gateway, and for Wi‑Fi the active AP) and emit networkChanged() only when it actually differs, which would also fix the symmetric gap described above where an AP change is noticed but never emits networkChanged().
  • Optionally, while the tunnel is up, let the Kill Switch allow the connectivity-check traffic, or add amn0 to NetworkManager in a way it counts (a 0.0.0.0/0 route on the interface instead of the two /1 halves), so the desktop stops reporting "no internet" for the entire session.
<!-- gh-comment-id:5866351341 --> @firefoxic commented on GitHub (Sep 28, 2026): Same root cause reproduced on a different protocol and with a second, deterministic trigger. Adding it here because it also explains a user-visible symptom that has no issue of its own. ### Environment - Fedora Silverblue 44, kernel 7.2.7, NetworkManager 1.56.1, GNOME Shell 50 - AmneziaVPN 5.0.3.0, self-hosted server, protocol AmneziaWG (userspace `amneziawg-go`, interface `amn0`) - Kill Switch enabled ### Where the reconnect comes from `client/platforms/linux/linuxnetworkwatcherworker.cpp`, `LinuxNetworkWatcherWorker::NMStateChanged()`: ```cpp } else if (state == NM_STATE_CONNECTED_GLOBAL) { emit networkChanged(); } ``` Every `StateChanged(70)` is mapped to `networkChanged()` unconditionally, and `VpnConnection` connects that signal straight to `reconnectToVpn()`. Nothing compares the physical network before and after, so a pure connectivity reclassification by NetworkManager is enough to tear the tunnel down. ### Why it is deterministic with Kill Switch on NetworkManager's connectivity check is an HTTP request bound to each interface separately. With Kill Switch on, the request leaving the physical interface is rejected by the firewall (immediate `Connection refused` from the local address), so that interface is permanently `limited`. NetworkManager computes its global state only from devices with a default route it configured itself. `amn0` is externally managed and carries `0.0.0.0/1` + `128.0.0.0/1` rather than `0.0.0.0/0`, so it is not considered at all. Result: while the VPN is up, NetworkManager sits in `CONNECTED_SITE` (`nmcli general` shows `limited` / `connected (site only)`). Any event that brings NetworkManager back to `CONNECTED_GLOBAL` now triggers a full reconnect. I hit it two ways: 1. Giving `amn0` a managed NetworkManager profile with a real default route (so the connectivity check on `amn0` counts). The check returned `full`, NetworkManager announced `CONNECTED_GLOBAL`, and the client reconnected within 70 ms, destroying the very interface that had just been made to work. Repeating the step gives an infinite loop. 2. Simply disabling NetworkManager's connectivity checking (`[connectivity] enabled=false`) while the VPN is connected. NetworkManager assumes `full`, goes to `CONNECTED_GLOBAL`, and the client reconnects once. Log from case 1 (times are local): ```text 11:14:03.174 NetworkManager: manager: NetworkManager state is now CONNECTED_GLOBAL 11:14:03.178 AmneziaVPN-service: LinuxNetworkWatcherWorker : NMStateChanged 70 11:14:03.241 AmneziaVPN.desktop: Reconnect triggered. Reconnecting to the server 11:14:03.243 AmneziaVPN-service: Daemon : Deleting routes for InterfaceConfig::SingleHop 11:14:03.376 NetworkManager: device (amn0): state change: activated -> unmanaged (reason 'unmanaged', managed-type: 'removed') 11:14:05.023 AmneziaVPN-service: WireguardUtilsLinux : Created wireguard interface amn0 ``` No Wi‑Fi involved at all: wired `ens9`, same gateway, same interface before and after. ### User-visible side effect Because NetworkManager is stuck in `CONNECTED_SITE` whenever Kill Switch is on, GNOME Shell draws the "no route" network icon (the grey icon with a question mark) for the whole VPN session, and desktop apps that use `GNetworkMonitor` see limited connectivity. The only workarounds are disabling Kill Switch or disabling NetworkManager's connectivity check system-wide, and the latter also removes captive portal detection (related to #3106). ### Suggested fix - Do not treat `CONNECTED_SITE -> CONNECTED_GLOBAL` (or `CONNECTED_LOCAL -> CONNECTED_GLOBAL`) as a network change. Only transitions from `DISCONNECTED` / `CONNECTING` into a connected state can mean a new network. - Better: track the physical identity (primary device path, gateway, and for Wi‑Fi the active AP) and emit `networkChanged()` only when it actually differs, which would also fix the symmetric gap described above where an AP change is noticed but never emits `networkChanged()`. - Optionally, while the tunnel is up, let the Kill Switch allow the connectivity-check traffic, or add `amn0` to NetworkManager in a way it counts (a `0.0.0.0/0` route on the interface instead of the two `/1` halves), so the desktop stops reporting "no internet" for the entire session.
Author
Owner

@dimadze1337 commented on GitHub (Nov 5, 2026):

Dirty workaround fix (worked for me):
sudo vi /etc/NetworkManager/conf.d/20-connectivity.conf

Add there:

[connectivity]
enabled=false

And then restart NetworkManager

sudo systemctl restart NetworkManager

<!-- gh-comment-id:6663915163 --> @dimadze1337 commented on GitHub (Nov 5, 2026): Dirty workaround fix (worked for me): sudo vi /etc/NetworkManager/conf.d/20-connectivity.conf Add there: [connectivity] enabled=false And then restart NetworkManager sudo systemctl restart NetworkManager
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#1442
No description provided.