Check VPN connection status (connect/disconnect) from the command line

How to check that a VPN connection is connected or disconnected using command line?


If you want to know if any VPN-connection is active then the following invocation is useful:

nmcli con | grep -i vpn

Depending of the connection status you will get either

VPN099     ...  vpn              wlan0

if active or

VPN099     ...  vpn               ---

if inactive.


This will show just the active connections:

nmcli con show --active

And you can grep for vpn, if needed:

nmcli con show --active | grep -i vpn

We can do this using nmcli command:

nmcli con status id your-vpn-connection-name

If your VPN connection is connected, you will see the connection information but if your VPN connection is disconnected, you will see something like this:

Error: 'your-vpn-connection-name' is not an active connection.