How can I tell if OS X is connected to a VPN network from the command line?
You can also, as of Mountain Lion1, use the scutil command.
For example:
$ scutil --nc list | grep Connected
For more detailed help, you can see the man page, or run:
$ scutil --nc help
Footnotes:
- I'm not aware of this command existing in versions of OSX previous to Mountain Lion, but I could be wrong.
Related videos on Youtube
cwd
Updated on September 18, 2022Comments
-
cwd almost 2 years
How can I tell if OS X is connected to a VPN network from the command line?
By running
ifconfig
without any arguments when I am connected, I see that there is autun0
interface which appears to be the VPN connection. When I disconnect it goes away.I believe I could use something like this to check for the string
utun0
and count the occurrences:ifconfig | grep -c utun0
But is there an easier or more effective way to check for this? If
utun0
is a device, or even a pseudo device, shouldn't I be able to check if it exists with something like:if [ -a '/dev/utun0' ]
Unfortunately I don't see any changes in that directory when connecting and disconnecting, I just see
/dev/tun0
through/dev/tun15
and I can'tcat
them even withsudo
...Is there a simpler way to tell if I have a VPN connection?
-
Admin about 11 yearsWhat kind of VPN? The built-in you configure in System Preferences?
-
Admin about 11 years@DanielBeck -yes
-