How to check is VPN connected on my Mac?

I want to see if my mac is connected to VPN using oc or c++.

I try to use "getifaddrs" to get all the network interface info, but find that the VPN interface type is "utun", not "ppp" or "ipsec", etc. For the VPN is created by com.apple.net.utun_control.

Any other way to check the VPN.

I want to see if my mac is connected to VPN

What high-level goal are you trying to achieve by detecting whether the “mac is connected to VPN”?

The reason this matters is that VPN’s are ridiculously complicated on our platforms. macOS VPNs come in three flavours:

  • Packet tunnel

  • App proxy (a type of per-app VPN)

  • Custom

And packet tunnels can be based on the destination IP address or the source app (another type of per-app VPN). And destination IP address packet tunnels can provide the default route or be limited to a specific set of destination networks.

Moreover, it’s possible to have multiple different layers of VPN running! And folks can use technologies that are not strictly dedicated to VPN, like a transparent proxy, as a VPN.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

How to check is VPN connected on my Mac?
 
 
Q