Observing OpenVPN Reconnects with NetworkManager

3 Total views across this article’s versions; includes the historical baseline where available.

Compare all DNS policies.

This guide follows the lifecycle state of one OpenVPN connection managed by NetworkManager. The DNS routing policies remain centered on iproute2 routes and rules, Netfilter restrictions, and resolver selection. They do not require OpenVPN, this observer, or an availability loop. See the three-part architecture, VPN operation guide, and separate DNS availability guide.

Keep Three Questions Separate

Question Evidence
Where is DNS permitted to go? Routing rules/tables and firewall policy
Is the OpenVPN session reconnecting? Client lifecycle events associated with that connection
Can the selected DNS service answer now? A separate DNS availability check

A client event does not install or weaken routing policy. A DNS failure is not proof that OpenVPN is reconnecting. An observer losing its own event stream means unknown, not permission to use a less private route.

What the Source Check Established

OpenVPN’s management protocol exposes RECONNECTING, CONNECTED, and other lifecycle states. state on all provides state history together with future notifications. Interface existence is insufficient because a reconnect can preserve the tunnel. The management interface supports one client at a time. OpenVPN management protocol

The NetworkManager-openvpn 1.12.5 release was rechecked on November 26, 2026 against the upstream tarball and published SHA-256 checksum. This identifies the inspected source; it does not assert that this version is installed on the proposed Ubuntu lab host. Its service supplies --persist-tun and --up-restart and owns a management socket. The inspected handler handles authentication messages but does not subscribe to or forward OpenVPN >STATE: notifications. The restart helper can resend IP configuration; that is not a dependable notification of the beginning of peer loss. This is a source finding about that release, not a runtime test of the user’s host. Upstream release, service source

NetworkManager exposes the public VpnState property and VpnStateChanged signal. Its core can map a plug-in transition from STARTED to STARTING to a reconnecting connection state, but the plug-in has to report that transition. The existence of the public API does not establish that every OpenVPN internal reconnect reaches it. Public VPN API, NetworkManager 1.46.0 core

Consequently, neither the tunnel interface, a generic active-connection indicator, nor vpn-up/vpn-down alone is sufficient evidence of internal reconnect coverage. NetworkManager also documents that vpn-pre-down is not emitted for forced disconnections, so it cannot be the only place that installs protection. Dispatcher events. A dispatcher hook needs verified coverage of these events before it can drive a reliable observer. Do not attach a second client to NetworkManager’s management socket or replace its existing OpenVPN helper scripts to obtain notifications.

Observe the Installed Combination First

The following is a read-only observation procedure, not an automatic failover implementation. Record the installed versions and the intended connection UUID. On Debian/Ubuntu, package versions can be read with:

nmcli --version
openvpn --version
dpkg-query -W network-manager network-manager-openvpn openvpn
nmcli -f NAME,UUID,TYPE connection show --active

On another distribution, use its package-query equivalent. Identify one connection by UUID rather than assuming that every OpenVPN message belongs to the same tunnel.

VPN_UUID='REPLACE_WITH_CONNECTION_UUID'
test "$VPN_UUID" != 'REPLACE_WITH_CONNECTION_UUID' &&
  nmcli -f GENERAL connection show --active uuid "$VPN_UUID"

Find the active connection’s D-Bus path in that output. In one terminal, begin observing that object before triggering a controlled reconnect:

ACTIVE_PATH='/org/freedesktop/NetworkManager/ActiveConnection/REPLACE'
gdbus monitor --system --dest org.freedesktop.NetworkManager --object-path "$ACTIVE_PATH"

In a second terminal, set ACTIVE_PATH to the same observed active-object path before requesting a snapshot. Shell variables from the first terminal are not inherited. Obtain the snapshot after the subscription is active:

gdbus call --system --dest org.freedesktop.NetworkManager --object-path "$ACTIVE_PATH" --timeout 5 --method org.freedesktop.DBus.Properties.Get org.freedesktop.NetworkManager.VPN.Connection VpnState

The public VPN states include CONNECT (3), ACTIVATED (5), FAILED (6), and DISCONNECTED (7). These are not the plug-in service-state enum, whose numeric values differ. Consult the VPN API types. A recreated active connection has a new object path; rediscover it by UUID and resubscribe. A stale path or lost bus connection is not a VPN-down event. GDBus commands

For diagnosis, inspect the NetworkManager journal and correlate it with the actual OpenVPN process belonging to this activation:

Use your existing lab root shell, or open one with sudo -i if this is a separate terminal:

journalctl -b -u NetworkManager -n 100 --no-pager
journalctl -b -u NetworkManager -f -o short-monotonic

Stop the foreground journal and D-Bus observers with Ctrl+C when the observation is finished. A returned snapshot and a stream of signals are separate observations, not an atomic history of every transition.

Some distributions route OpenVPN records differently. Confirm the actual unit, identifier, PID, and activation before choosing a filter. Preserve the unfiltered evidence for the target process; do not turn a broad text search for “restart” into a policy trigger. Journal messages can help demonstrate a reconnect, but log wording, delivery, and process identity require validation before any parser could be trusted for automation. Do not enable secret-bearing debug logging just to make an example work. Journal filtering

Validate Internal Reconnects, Not Just Deliberate Disconnects

Keep independent recovery access. On a disposable lab connection, arrange loss of the recorded VPN peer path while leaving the host’s normal connection available. Use the configured OpenVPN timeout; do not assume a universal interval or overwrite provider-supplied settings. Test an internal restart separately from a NetworkManager deactivate/reactivate operation.

Record the OpenVPN evidence, D-Bus events, interface state, and timing together. A passing observation must expose loss of the session even when the interface remains, then distinguish renewed session establishment from subsequent route installation and DNS availability. A reconnect event caused by an administrative restart also must not be mislabeled as proof of a network outage. Include process replacement, changed object paths, rapid reconnects, and loss of the observer itself.

Do not infer success from the interface disappearing once, from a later IP-configuration update, or from DNS beginning to work again. The failure transition itself must be observable on the installed versions.

Boundary for a Future Adapter

A reliable automatic adapter needs a supported, verified event path from the OpenVPN client through the connection owner, including internal restarts. The checked plug-in source does not establish that path. Adding state forwarding to the owner, or selecting a version/integration that already supplies it, is separate engineering work; no plug-in patch, management proxy, service, or automatic routing hook is installed by this review.

If that integration is later validated, the adapter can report session unavailable, session established, or unknown for one UUID/activation. The routing policy still decides whether direct fallback is permitted. Established means the session exists, not that the selected DNS server is responsive. Any DNS readiness policy belongs to a separate availability discussion.

For now, the routing tutorial’s explicit mode-switch commands remain independently usable and testable. Reliable automatic internal-reconnect integration through this checked NetworkManager plug-in remains an identified limitation. The separate advanced Ubuntu walkthrough uses dedicated Community 2.6/systemd instances with their own management owner; it does not establish a fix for this plug-in. No Linux runtime tests have been performed.

Review History

Preserved earlier draft (text). Source and local page review: November 26, 2026; integration-scope clarification: November 29, 2026. This NetworkManager observation procedure and its proposed automatic integration remain untested on Linux.

Additional reference: nmcli connection selection and active data.