VPNStatus icon indicating copy to clipboard operation
VPNStatus copied to clipboard

Shut Off All VPNs with vpnutil

Open lukerbs opened this issue 2 years ago • 2 comments

Hi,

Is there a way to shut off all VPNs with a single command using vpnutil?

Thanks

lukerbs avatar Dec 06 '21 22:12 lukerbs

vpnutil can stop one single VPN with the command:

vpnutil stop MyVPN

It has no built-in command to stop all VPNs (could be an interesting new feature). However you could write a simple script using vpnutil to stop each VPN one by one. For example a bash script like:

#!/bin/bash

vpnutil stop MyVPN1
vpnutil stop MyVPN2

Timac avatar Dec 10 '21 21:12 Timac

@lukerbs you can use the following bash script using the new machine readable vpnutil list output (assumes you also have jq CLI installed):

#!/usr/bin/env bash

ORIG_IFS="${IFS}"
IFS=$'\n'
for vpn_name in $(vpnutil list  | jq -r '.VPNs[].name'); do
  vpnutil stop "${vpn_name}"
done
IFS="${ORIG_IFS}"

dronenb avatar Jan 25 '24 04:01 dronenb