title: How VPN works in Android and List of APIs available? (lollipop)
body: <p>###Reference:</p>
  <p>Android 4.0 has an API to build VPN services.</p>
  <ol>
  <li><a href="https://developer.android.com/reference/android/net/VpnService.html" rel="nofollow noreferrer">VPNService (Android Docs)</a></li>
  <li><a href="https://developer.android.com/reference/android/net/VpnService.Builder.html" rel="nofollow noreferrer">VPNService.Builder (Android Docs)</a></li>
  <li><a href="https://github.com/schwabe/ics-openvpn" rel="nofollow noreferrer">Arne Schawbe's Implementation of OpenVPN for Android (github)</a></li>
  </ol>
  <p>One such app with a VPN service is <a href="https://play.google.com/store/apps/details?id=com.nmwco.mobility.client&amp;hl=en" rel="nofollow noreferrer">NetMotion Mobility® (Google Play)</a></p>
  <p>Beginning with the &quot;Lollipop&quot; version, Android come with a new VPN type which provides information about VPN connection state, whether requests go over the VPN, etc.</p>
  <p>###Test Results</p>
  <p>(Connected to VPN)</p>
  <ol>
  <li>Android &lt; =5.0(Android Lollipop)</li>
  <li>Connection is successful with WIFI(Wlan) and Cellular(rmnet) interface IP’s.</li>
  <li>Connection is successful with VPN(tun) interface IP address but does not get VPN connected/disconnected events.</li>
  <li>Android &gt; 5.0(Android Lollipop 5.1 and 6.0)</li>
  <li>Connection is <strong>not</strong> Successful with WIFI(Wlan) and Cellular(rmnet) interface IP’s.</li>
  <li>Connection is successful with VPN(tun) interface IP’s address and also get VPN connected/disconnected events.</li>
  </ol>
  <p>tun interface IP: <a href="https://i.stack.imgur.com/bpUXC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bpUXC.png" alt="SITE local Private IP()." /></a></p>
  <ol>
  <li><a href="https://developer.android.com/reference/android/net/ConnectivityManager.html#TYPE_VPN" rel="nofollow noreferrer">ConnectivityManager#TYPE_VPN</a></li>
  <li><a href="https://developer.android.com/reference/android/net/NetworkCapabilities.html#TRANSPORT_VPN" rel="nofollow noreferrer">NetworkCapabilites#TRANSPORT_VPN</a></li>
  <li><a href="https://developer.android.com/reference/android/net/NetworkCapabilities.html#NET_CAPABILITY_NOT_VPN" rel="nofollow noreferrer">NetworkCapabilities#NET_CAPABILITY_NOT_VPN</a></li>
  </ol>
  <blockquote>
  <p>Indicates that this network is not a VPN. This capability is set by
  default and should be explicitly cleared for VPN networks. Constant
  Value: 15 (0x0000000f)</p>
  </blockquote>
  <p>###Questions:</p>
  <ol>
  <li>When the VPN service is active on the device how do requests work from 3rd party apps like WhatsApp, Skype or the browser?</li>
  <li>When the VPN is connected what exactly happens to the device IP stack?</li>
  <li>How does VPN tunneling work in Android?</li>
  <li>What is the design for an app which binds to active IP and sends requests?</li>
  <li>Are the VPN APIs in lollipop (5.0) not stable?</li>
  <li>If <a href="https://stackoverflow.com/questions/28272479/app-process-network-setprocessdefaultnetwork-bindprocesstonetwork-android-api">bindProcessToNetwork</a> is done over Celluar network and WiFi is connected in device, which network will the VPN use?</li>
  </ol>