I would like to get the VPN connection status in a script.

On macOS 13.2.1 I have two VPNs configured (i believe both are of type IKEv2) but i can see neither of them using

  • scutil --nc list nor
  • networksetup -listpppoeservices.

Is there another way to query the status of these VPNs?

  • A VPN will create or use an existing virtual interface (i.e. utunX)to route traffic through. Which interface does your VPN use?
    – Allan
    Feb 23 at 14:26
  • networksetup -listpppoeservices used to work for me but it suddenly stopped listing my VPN configuration. I even recreated the VPN configuration under network settings but it's still not listed. I'm not sure if this is deliberate or a bug in macOS 13.2.1. Mar 8 at 10:19

1 Answer 1


If you are speaking of a VPN used to access a private network, perhaps the easiest approach would be to check if an IP address specific to that network is reachable.

For example, if your VPN connects you to a network, using ping to check if (probably the gateway) is reachable:

if ping -c 4 &> /dev/null
  echo "connected"
  echo "not connected"

Solution copied from this answer (in my example, -c 4 tries 4 times).

If you are using a VPN to avoid blocking, you might instead test against any IP address that is otherwise blocked.

This approach is not very sophisticated, but its advantage is its simplicity, and that it should work independent from the type of VPN and also on most operating systems.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .