mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-12-03 19:50:19 +07:00
[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
No Branch/Tag specified
dev
feat/pages-ui-tests
feat/otp-free-users-login
fix/refresh-external-ip-and-proxy-config-in-start-sh
fix/ios-keep-nav-bar-below-status-bar-and-lift-rename-sheet-over-keyboard
fix/ios-stop-hev-before-restarting-xray-tunnel
feat/whatsapp-proxy
fix/keep-socks-and-pfx-secrets-out-of-command-lines
fix/pass-the-tunnel-config-over-a-named-pipe
feat/test-xray-pages-ui
fix/expect-server-xray-v26.10.31
fix/align-xray-settings-with-core-defaults-and-add-contract-tests
feat/xtun
feat/separated-ui-models-and-controllers-tests
fix/keep-default-godebug-when-disabling-async-preemption
feat/otp-login
feat/android-tests
fix/server-removal-navigation-and-sheet-reopen
feat/add-deep-link
feat_copy_docker_configs
fix/gateway-requests-on-slow-or-blocked-dns
fix/bypass-proxy
feat/api-tests
fix/serialize-log-record-writes-and-pin-log-date-format-locale
fix/libagw-review-fixes
fix/ios-xray-ipv6-leak
fix/macos-xray-ipv6-leak
feat/add-support-include-split-tunnel
fix/win-xray-app-split-tunneling
fix/bug-when-saving-after-canceling
fix/xray-reconnect-crash
fix/share-empty-config-on-ssh-timeout
fix/ssh-credentials-input
fix/updater-verify-signature
fix/async-ssh-threading
fix/xray-check-inet-and-liveness-monitor
fix/selfhosted-server-installations
feat/add-support-ikev2-macos
fix/icons-different-color-themes
feat/add_support_arm_windows
feat/fixed-push-notifications-on-VPN-connect-disconnect-2
feat/implement-QR-code-generation-and-scanning
feat/file-password-protection
feat/add-support-split-tunnel-macos
feat/tests
fix/android-register-unacknowledged-purchase
fix/share_on_linux
mirroring-to-outside
feat/self-diagnostics-log
feat/amnezia-free-vless-switch
fix/conan_build_android_on_win
fix/linux-reconnect-dns-reliability
fix/windows-connection-stability
fix/linux-reconnect-refactoring
fix/ios-groupidentifier-order
feat/xray-subscription-link
fix/minor-fixes
fix/xray-config-inplace-edit
feat/amnezia-sdk-typed-api
feat/amnezia-sdk-integration
feat/force-update-native
refactor/marketplace-update-popup
feat/force-update
fix/valnurability_dev
chore-xcode-version
fix/empty-i1-i5
build_qt_6_10_1
master
feat/protocol-selection
fix/openvpn_install
feat/locations_change
feat/locations_change_rework
feature/local-proxy-integration
fix/filepicker_atv
fix_valnurability
fix/macos-ne-codesign-4.8.19.0
temp-branch-for-testing
fix/rebased_4_8_19_linux_fix_error
feat/proxy-storage-cache
fix/zeroed-params
fix/killswitch-blocknets-linux
update/translation_RU
fix/self_hosted_reinstall_error
feat/selfhosted-dns
fix/agp_version_up
feat/switch_to_alive_protocol
feat/support_multipeer
server_scripts_update
fix/extended-vless-configuration
chore/apple-ci-cd-macos-versions
feat/add-telemt
fix/android_keystore_read_error
feat/add-mtproxy
chore/bump-qt-version
fix/make_dbus_async
feature/dns
rebase/apple-tv-target-on-conan
fix/outbound_freedom_xray_with_dns_fix
feat/apk_support
feat/fallback-proxy
feat/apple-tv-target
fix/dns_reconnection_issue
feat/fixed-push-notifications-on-VPN-connect-disconnect
fix/linux-firewall
docker-regional-locks
appstore-review-popup
feat/storekit2
fix/uninstall-split-tunnelling-driver
revert-2376-chore/license-file
support_16kb_android
bump_version
feat_add_review_android
bugfix/translation-absence-on-subscription-key-page
feat/location-separation-by-region
bugfix/text-moving-when-resing-window
fix_backup
feature/add-purchase-android
bugfix/moved-text-while-resizing-window
bugfix/incorrect-killswitch-restore-from-backup
fix/backup-exclude-secondary-api-configs
feat/proxy-fields-for-dev-console
bugfix/ovpn-ios-fix
bugfix/linux-bundle-libraries
fix/xray-app-split-win
fix/upload-to-s3
chore/add-release-date-upload
feat_add_webview_support
feature/configuration-transfer-through-qr
feat/bot-key-unlink-device
fix/ad-link-lang-support
fix/qsecuresettings-with-android
feat/add-support-arm64-win
spanish-translations
fix/context-menu
feat/add-system-dns-support
fix/qt6-9-support
fix/qt6_9_support
bugfix/strict-killswitch-ui
android-7
chore/minor-bugfixes
feature/awg-net-fix-macos-wakeup
fixbug/ios18
bugfix/ios-ne-crash
fix/linux-tray-quit-button
cryptpad-support
bugfix/disable-linux-killswitch
fix/minor-ui-fixes
feature/setup-guid-tun2socks
feature/linux-ipsec
feature/ipsec-linux
refactoring/server-config-in-classes
feature/macos-ipsec
fix/ui-fixes-after-merge-with-d20ed4a
chore/focus_control_after_qt_6.9_migration
feature/integrate-xray-as-a-library
maxos-awg-fix
feature/add-new-awg-docker-image
chore/update-3rd-prebuild
feature/test-news
fix/api-conf-files
bugfix/split-tunneling-with-api-config
bugfix/ios-awg-new-fields
feature/special-handshake-2
feat/xray-api-support
fix/desktop-entry
bugfix/shadowsocks-cipher-setting-not-changing
feature/update-tap
bugfix/openvpn_import_fix
feature/ability-to-change-port-after-installing-xray
bugfix/strict-mode-ovpn
bugfix/win-ipv6-ovpn
bugfix/subnet-adress-setting
exception-podman-docker
bugfix/fix-listviewtype-scrolling
bugfix/win-disabled-ipv6
bugfix/win-ipv6-disabled-ovpn
feature/killswitch-strict-mode
feature/awg-network-check
feature/empty-split-tunneling-list
feature/support-info
chore/update-go-version
checking-Linux-version
update_server_scripts
bugfix/button-selection-easy-setup-page
feature/old-api-proxy
patch/user-checking
fix/correcting-version
support-podman
support_podman
user-checking-patch
feature/check-docker-version
feature/allowed-dns-list
without_lsof
chore/error-body
Update-amneziavpn_ru_RU
shiroow-patch-8
shiroow-patch-7
shiroow-patch-6
shiroow-patch-5
shiroow-patch-4
shiroow-patch-3
shiroow-patch-2
shiroow-patch-1
check_sudo_permissions
feature/euphoria
add_next_octet_to_ip_settings
bugfix/mobile-controllers-init
euphoria
bugfix/android-crush
feature/macox-network-extension
bugfix/pre-release-hotfixes
bugfix/ipsec-pfs
chore/ios-site-links
checking_sudo_permissions
feature/android-tv
improve_navigation_cpp
bugfix/linux-firewall-install
fixbug/wireguard-handshake-time
ReadmeRu_full
feature/xray-user-management
feature/subscription-end-date
chore/clang-format
feature/ru-in-readme
chore/increased-api-timeout
chore/deploy-workflow
bugfix/services-list-scroll
wheel_group_suppor
chore/bump-xcode-version
fixbug/mac-network-extension
feature/android-gpb
feature/page-home-drawer-country-selection
checking-sudo-users
bugfix/service-info-from-response
fixbug/build-macos-ne-2
android-qt-6.7.3
fixbug/build-macos-ne
bugfix/wg-windows-log-folder
feature/psk-key-api-request
bugfix/user-management-qml-warnings
fix/macos-network-extension
fixbug/macos-NE-build
bugfix/fixed-isDevEnv-initialization
bugfix/revert-ios-ovpn
feature/tun2socksSrv
fix/disable_singleapp
feature/awg-wg-name-resolving
feature/disable-dhcp
bugfix/allowed-ips-old-configs
feature/goodbyedpi
feature/add-exception-log
refactoring/remove-ipv6-from-default-routes
refactoring/singleapplication-submodule
macos-dirty-build
test/gateway
Update-amneziavpn_fa_IR.ts
bugfix/ipsec-win
fix/xray-custom-port
improve-tab-navigation
test-win-11
feature/android-tv-remote-control-support
KsZnak-patch-1
feature/awg-wg-qr
bugfix/fix-loopback-splittunel
fix/setup_host_firewall
feature/android-xray
feature/openvpn-pass
feature/connection-string
fix/clickable-errors
bugfix/api_1100_fix
feature/graphview
testsvg
feature/update-win-awg
feature/open-as-amnezia
feature/update-mozilla-upstream
bugfix/qr-code-cutting
feature/native-wg-psk
test/awg-centos
bugfix/hide_error
feature/add-uninstaller-checkbox
bugfix/cancel-button-on-install-page
bugfix/anchors-page-home-warning
awg-udptlspipe
button-focus-fix
revert-677-fix/logger
bugfix/Revert_PR_596
bugfix/allowed-ips-api-configs
bugfix/on-escape-pressed
feature/auto-scroll-for-server-selection-list
fix/ui-fixes
translations/update_fa_IR.ts
feature/new-awg-docker-container
bugfix/awg_ipv6_fix
feature/tab-navigation
fix/username-no-autocapitalization
sure
refactoring/servers-model-cleanup
feature/wg-mtu-setup-ios
3rd_adaptation_to_diff_OS
sudo_not_found
test/docker-ce
bugfix/double_clear_server_from_amnezia
fix/android
client/3rd-prebuilt
revert-559-KsZnak-translation-ru-ex
KsZnak-translation-ru-ex
KsZnak-br1
KsZnak-text-change
feature/api-awg
feature/error-code-output
feature/win_x32_builds
text/debug-output
feature/ovpn3-desktop-cli
bugfix/secureqsettings-deadlock
refactoring/change-settings-when-connected
files_check
ArchLinux-support
second_adaptation_to_diff_os
sudo
refactoring/android-build
adaptation_to_different_os
feature/online_installer_for_v4
update_to_r2
bugfix/return-after-installation
feature/custom_drawer_component
bugfix/split-tunneling
bugfix/existing-awg-container
revert-370-feature/custom_drawer_component
bugfix/adapted_awg_questiondrawer
bugfix/updated_drawer_height_pageserverdata
bugfix/translated_new_source_strings_to_chinese
feature/split-tunneling-config
feature/accessibility-support
branch_connectivity_change_fix
feature/ikev2_android
android_ss_transport
bugfix/macos_fixes
feature/nextcloud-support
feature/macos_network_extension
android_pt_transport_source
feature/ios-openvpn3-pluggable-transport-Cloak
bugfix/cloak_for_desktops_fix
arm-build-macos
fix-macos-build-brew
bugfix/ios-build-openvpnadapter-from-source
feature/download-native-wireguard-config-on-connect
feature/v2ray-container
bugfix/dpkg-busy-checking-stuck
feature/online-installer
dev-killswitch
dev-netadapters
5.1.0.6
5.0.4.2
5.0.4.1
5.0.4.0
5.0.3.0
5.0.2.1
5.0.2.0
5.0.1.5
5.0.0.5
5.0.0.2
4.8.21.0
4.8.19.0
4.8.18.0
4.8.17.0
4.8.16.0
4.8.15.4
4.8.15.0
4.8.14.5
4.8.14.1
4.8.12.9
4.8.12.8
4.8.12.7
4.8.12.6
4.8.11.4
4.8.11.3
4.8.11.2
4.8.11.1
4.8.11.0
4.8.10.0
4.8.9.2
4.8.9.1
4.8.9.0
4.8.8.3
4.8.8.2
4.8.8.1
4.8.7.2
4.8.7.1
4.8.7.0
4.8.6.0
4.8.5.0
4.8.4.5
4.8.4.4
4.8.4.3
4.8.4.2
4.8.4.1
4.8.4.0
4.8.3.2
4.8.3.1
4.8.2.3
4.8.1.9
4.8.1.0
4.8.0.5
4.7.0.0
4.6.0.3
4.6.0.1
4.5.3.0
4.5.0.0
4.4.0.0
4.3.0.0
4.2.1.0
4.2.0.1
4.1.2.0_cloak_pt_experimental
4.1.0.1
4.0.8
3.1.0
3.0.8
3.0.7
3.0.5
2.1.2
2.1.0
2.0.10
2.0.9
2.0.8
2.0.7
2.0.6
2.0.5
2.0.1
2.0
1.9.1
1.9
1.8
1.7
1.6
1.5
1.4
1.3
1.2
1.1
1.0
No labels
pull-request
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
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
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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:
even when the physical network, Wi-Fi access point, interface, and gateway have not actually changed.
A normal NetworkManager connectivity transition:
is interpreted by AmneziaVPN as a network change.
When NetworkManager returns to
CONNECTED_GLOBAL, AmneziaVPN callsVpnConnection::reconnectToVpn(). With Xray this stops Xray/tun2socks, destroystun2, 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
tun2+tun2socks10.33.0.2/24Reproduced timeline
Incident captured on 2026-08-31.
NetworkManager changes connectivity classification
NetworkManager then retries connectivity checks.
Approximately 31 seconds later:
The important part is that AmneziaVPN itself reports that the access point did not change.
AmneziaVPN immediately reconnects
Immediately after
NMStateChanged 70:The existing TUN is then removed:
The diagnostic bundle independently confirms that the TUN FD was owned by Amnezia's
tun2socksprocess.Cleanup errors
During this automatic reconnect the logs also contain:
and several route deletion failures.
A
pkillinvocation also reports:Tunnel is recreated
AmneziaVPN then starts Xray/tun2socks again and creates a new TUN:
Therefore the
tun2deletion 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:
contains:
Therefore every NetworkManager transition to
CONNECTED_GLOBALbecomesnetworkChanged().LinuxNetworkWatcherforwards it:The service exposes it through IPC:
and
VpnConnectionconnects that directly to:reconnectToVpn()performs:The effective Linux behavior is therefore:
But
CONNECTED_GLOBALis 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:
That change added:
There is also relevant earlier history.
Commit:
contained:
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:
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:
to:
Periodic
connectivity-check.ubuntu.comchecks 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_GLOBALwith a physical network change.Expected behavior
A pure connectivity-classification transition:
must not cause a full VPN reconnect by itself.
Reconnect should happen when there is evidence of a real underlying-network change, for example:
NetworkManager Internet-connectivity classification should not be used as a substitute for these checks.
Suggested fix
Please do not use:
by itself as the condition for
networkChanged().A robust implementation could compare a physical-network identity tuple before reconnecting, for example:
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:
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.
@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
-> 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:
same AP/interface/gateway, SITE -> GLOBAL
reconnect count = 0
AP-A -> AP-B, global connectivity remains available
physical-path reconciliation count = 1
Wi-Fi -> Ethernet
reconciliation count = 1
CONNECTED_GLOBAL repeated N times, identity unchanged
reconnect count = 0
enter ASLEEP
reconnect count = 0
resume, path becomes usable
one controlled reconciliation
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.
@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
amneziawg-go, interfaceamn0)Where the reconnect comes from
client/platforms/linux/linuxnetworkwatcherworker.cpp,LinuxNetworkWatcherWorker::NMStateChanged():Every
StateChanged(70)is mapped tonetworkChanged()unconditionally, andVpnConnectionconnects that signal straight toreconnectToVpn(). 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 refusedfrom the local address), so that interface is permanentlylimited. NetworkManager computes its global state only from devices with a default route it configured itself.amn0is externally managed and carries0.0.0.0/1+128.0.0.0/1rather than0.0.0.0/0, so it is not considered at all. Result: while the VPN is up, NetworkManager sits inCONNECTED_SITE(nmcli generalshowslimited/connected (site only)).Any event that brings NetworkManager back to
CONNECTED_GLOBALnow triggers a full reconnect. I hit it two ways:amn0a managed NetworkManager profile with a real default route (so the connectivity check onamn0counts). The check returnedfull, NetworkManager announcedCONNECTED_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.[connectivity] enabled=false) while the VPN is connected. NetworkManager assumesfull, goes toCONNECTED_GLOBAL, and the client reconnects once.Log from case 1 (times are local):
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_SITEwhenever 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 useGNetworkMonitorsee 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
CONNECTED_SITE -> CONNECTED_GLOBAL(orCONNECTED_LOCAL -> CONNECTED_GLOBAL) as a network change. Only transitions fromDISCONNECTED/CONNECTINGinto a connected state can mean a new network.networkChanged()only when it actually differs, which would also fix the symmetric gap described above where an AP change is noticed but never emitsnetworkChanged().amn0to NetworkManager in a way it counts (a0.0.0.0/0route on the interface instead of the two/1halves), so the desktop stops reporting "no internet" for the entire session.@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