nmcli - Disconnect VPN Without Specifying ID or UUID
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
NetworkManager |
Fix Released
|
Medium
|
|||
NetworkManager-OpenVPN |
New
|
Undecided
|
Unassigned | ||
network-manager-vpnc (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
In a recent attempt to eliminate steps when switching between VPNs ( https:/
Currently, in order to disconnect a VPN, you have to specify its id or uuid. I'm proposing that a general disconnection feature be added that will disconnect any connected VPN without having to specify its id or UUID.
This need becomes more clear when you attempt to automate switching between VPNs, as I describe in this comment:
https:/
As you can see, without this proposed feature, switching between VPNs is very verbose to automate.
I wish there was a command like this:
nmcli con down allvpn
This proposed command would disconnects any currently connected VPNs (without the necessity of specifying their id or uuid).
Changed in network-manager: | |
importance: | Undecided → Unknown |
status: | New → Unknown |
Changed in network-manager: | |
importance: | Unknown → Medium |
status: | Unknown → New |
Changed in network-manager: | |
status: | New → Fix Released |
If you are connected to a VPN, this command will return a list of established VPN connections: s]+\s){ 1,}[\s] {2,}){4} yes.+$'
nmcli con status | grep -oP '^(([^\
This command will list the IDs of any established vpn connections (one per line): s]+\s){ 1,}[\s] {2,}){4} yes.+$' | grep -oP '^.*?(?=\s{2,})'
nmcli con status | grep -oP '^(([^\
So to disconnect all VPN connections you could do it based on this ID like this: s]+\s){ 1,}[\s] {2,}){4} yes.+$' | grep -oP '^.*?(?=\s{2,})' | sed 's/^/\x27/' | sed 's/$/\x27/' | xargs -L1 nmcli con down id
nmcli con status | grep -oP '^(([^\
However, perhaps it is better to do this using the UUIDs.
You can list the UUIDs of all established VPN connections like this: s]+\s){ 1,}[\s] {2,}){4} yes.+$' | grep -oP '(?<=[\ s]{2})[ ^\s]+(? =(\s+[^ \s]+){2} \s+yes. *)'
nmcli con status | grep -oP '^(([^\
So you can disconnect all established VPN connections by UUID like this: s]+\s){ 1,}[\s] {2,}){4} yes.+$' | grep -oP '(?<=[\ s]{2})[ ^\s]+(? =(\s+[^ \s]+){2} \s+yes. *)' | xargs -L1 nmcli con down uuid
nmcli con status | grep -oP '^(([^\
Perhaps this logic could be added to nmcli, so that this following proposed option would concisely achieve the same results:
nmcli con down allvpn