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

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

4 Answers

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
1

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.
3

The answer is great and 100% works for me

nmcli con show --active

But when I started use openconnect as Cisco Anyconnect alternative, instead of:

nmcli con show --active | grep -i vpn

I had to use next:

nmcli con show --active | grep -i tun

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like