title: Linux/Unix check if VPN connection is Active/Up
body: <p>I have a code which detects if OpenVPN connection is up or down:</p>
  
  <pre><code>if echo 'ifconfig tun0' | grep -q "00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00"
  then
  echo "VPN up"
  else
  echo "VPN down"
  fi
  exit 0
  </code></pre>
  
  <p>now I'm trying to re-write the code to work with PPTP or IPSEC connection. I've tried to do:</p>
  
  <pre><code>if echo 'ifconfig ppp0' | grep -q "00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00"
  </code></pre>
  
  <p>or the same with ipsec but does not work. Is there any other way to detect PPTP or IPSEC connection?</p>