VPN-based USB "reverse tether"
C Java Shell C++
Switch branches/tags
Nothing to show
Clone or download
Latest commit 304749e Sep 18, 2013
Permalink
Failed to load latest commit information.
jni Initial commit Sep 22, 2013
res/values Initial commit Sep 22, 2013
src/vpntether Initial commit Sep 22, 2013
.classpath Initial commit Sep 22, 2013
.gitignore Initial commit Sep 22, 2013
.project Initial commit Sep 22, 2013
AndroidManifest.xml Initial commit Sep 22, 2013
LICENSE Initial commit Sep 22, 2013
README.md Initial commit Sep 22, 2013
build.xml Initial commit Sep 22, 2013
project.properties Initial commit Sep 22, 2013
run.sh Initial commit Sep 22, 2013

README.md

VPN-based USB "reverse tether"

Reverse tethering routes traffic from the device via host gateway over USB. This allows the Android device to access the network through the host without depending on Wifi or Bluetooth.

This method leverages VpnService API and does not require root access.

Technical details

+-----------------------+                  +------------------------+
|    Android Device     |                  |       Linux Host       |
|-----------------------|                  |------------------------|
|                       | Android          |                        |
|         ^ iptables    | VpnService       |          ^ iptables    |
|         |             |                  |          |             |
|     +--------+        |                  |      +--------+        |
|     |  tun   |  ---------                |      |  tun   |  ---------
|     +--------+        |  \               |      +--------+        |  \
|         ^             |                  |          ^             |
|         | forward()   | TetherService    |          | forward()   | forwarder
|         v             |                  |          v             |
|    +----------+       |  /               |   +---------------+    |  /
|    | unix sock| ---------                |   | TCP/unix sock | ------
|    +----------+       |                  |   +---------------+    |
|         |             |                  |          |             |
|         |             |                  |          |             |
|     +--------+        |                  |      +--------+        |
|     |  adbd  |        |                  |      |  adb   |        |
|     +--------+        |                  |      +--------+        |
|         +             |                  |          +             |
|         |             |                  |          |             |
+---------|-------------+                  +----------|-------------+
          |                                           |
          |                                           |
          |     adb forward XXX localabstract:YYY     |
          +-------------------------------------------+

Installation

ant

  1. Get Android SDK and NDK. Using the SDK manager, get build tools.

  2. Build the native library:

     $(ANDROID_NDK)/ndk-build
    
  3. Build the apk and install it:

     ANDROID_HOME=$(ANDROID_SDK) ant debug install
    
  4. Build the host-side forwarder:

     make -C jni
    

Eclipse

  1. Get Android Development Tools and Android Native Development Tools.

  2. Import existing project into workspace and build.

  3. Build the host-side forwarder:

     make -C jni
    

Usage

  1. Start the VPN service:

     ./run.sh setup  # You will be asked for sudo password.
    

    Wait for the alert dialog.

  2. Start the tunnel:

     ./run.sh run  # You will be asked for sudo password.
    

    You should see a key icon in the status bar.

  3. When done, press Enter to stop the tether.

License

See LICENSE.