Home » How to set up reverse tethering over USB?

How to set up reverse tethering over USB?

Solutons:


I recently discovered SimpleRT which works very well with Linux (and apparently OSX as well). Simply enable USB Debugging on your device (no root required), install the APK linked from that page on your device and connect it to your PC via USB, and then run the binary on your PC.

It will set up the connection as a VPN tunnel (tun0 by default) and your device should prompt you to (a) allow SimpleRT to create/oversee the VPN connection as well as (b) whether to run it when the device is configured as a particular USB accessory (which is what the binary does).

The project does not include a pre-built binary, so I’ve uploaded one I built for Ubuntu.


Below is a manual method that should work on Linux or Windows: http://blog.mathieu.carbou.me/post/60454997009/reverse-usb-tethering-with-android-2-2

STEP 1:

For Windows: Install USB drivers from Android SDK

For Linux: Nothing to do

STEP 2:

On Nexus One: Connect USB cable and activate USB Tethering. You should see on linux or windows a new network interface.

STEP 3:

On Linux Computer, setup a bridge:

# usb0 is the new network interface
# eth0 is the main interface connected to internet (or a gateway)

sudo ifconfig eth0 0.0.0.0  
sudo ifconfig usb0 0.0.0.0  
sudo brctl addbr br0  
sudo brctl addif br0 eth0  
sudo brctl addif br0 usb0  
sudo ifconfig br0 up  
sudo dhclient br0

See https://help.ubuntu.com/community/NetworkConnectionBridge to setup bridges

On windows, Bridge the 2 network interfaces

STEP 4:

Setup usb0 interface of your phone. You have to options:

  1. From your computer, execute:

    ./adb shell netcfg usb0 dhcp
  2. Or in a root terminal on your phone, type:

    su
    netcfg usb0 dhcp

You should now be able to connect to Internet on your phone using your computer’s Internet connection.

Try to do a ping www.google.com to be sure !

STEP 5:

To shut down the reverse-tethering, first unbridge interfaces on your computer:

sudo ifconfig eth0 down  
sudo ifconfig usb0 down  
sudo ifconfig br0 down  
sudo brctl delbr br0  
sudo ifconfig eth0 up  
sudo dhclient eth0

Then on your phone, uncheck the USB Tethering option !

You can also use Windows to create a WiFi network (using Connectify) and connect your device to that: http://www.nexusoneforum.net/forum/nexus-one-faq-how-tos/3133-reverse-tether-getting-internet-your-phone.html

There are some more possibilities — but all of them I know of require a rooted device.

Using the Reverse Tether App

First, there’s an App named Reverse Tether available for free on the Play Store (it’s a limited trial, which restricts the time you can be connected — but at least you can test this way whether your device is fully supported; the full version is about USD 5). According to an article at AndroidAuthority, setup should be as easy as 1-2-3: Plug in the USB cable, start the app, let it auto-configure (manual configuration is available as well) — and there you go. You can also let it ask you to connect when it finds an USB-connection.

Manual methods using Wifi

I know, this is not USB — but for completeness (and giving alternatives) I thought I might add these as well:

fiddling with the system and patching around

Several manual methods are available as well (and described e.g. at XDA) — but they are mostly technically complex, and expecting you to patch system files; not for the every-day-user, but rather for the tech-freak.

Terminal and go

However, another nice method should just involve 3 lines in the terminal, and is described in a post here, to connect to an ad-hoc Wifi network. Basically, it should go like this:

su
ifconfig wlan0 up
iwconfig mode auto;
iwconfig wlan0 essid "your SSID" channel 11 mode auto
ifconfig wlan0 10.0.0.x netmask 255.255.255.0

manipulating some config file

Another quite easy method is also described here, and involves editing the wpa_supplicant.conf file once (manually adding your ad-hoc Wifi network).

Easy-Peasy method

Do I need to say, really? Use a Wifi router. There are even some small “Travel routers” around for less than USD 50. And then connect your phone like you use to connect it to other Wifi networks…

I know this is an even later answer, but it is worth mentioning it.

No rooting needed!

No app installation needed!* Which is not even possible if you do not have some other internet connection.

There is a project called gnirehtet.

  1. Install adb on to the host PC (Windows/Linux/Mac)
  2. Download the gnirehtet zip-file to the host
  3. Unzip it
  4. Run the command

That’s it! For more information, read the readme file of gnirehtet on their website.

*=Behind the scenes it will install an apk file on to your device via the USB connection.

Related Solutions

Why not use “which”? What to use then?

Here is all you never thought you would ever not want to know about it: Summary To get the pathname of an executable in a Bourne-like shell script (there are a few caveats; see below): ls=$(command -v ls) To find out if a given command exists: if command -v...

Split string into Array of Arrays [closed]

If I got correct what you want to receive as a result, then this code would make what you want: extension Array { func chunked(into size: Int) -> [[Element]] { return stride(from: 0, to: self.count, by: size).map { Array(self[$0 ..< Swift.min($0 + size,...

Retrieving n rows per group

Let's start with the basic scenario. If I want to get some number of rows out of a table, I have two main options: ranking functions; or TOP. First, let's consider the whole set from Production.TransactionHistory for a particular ProductID: SELECT...

Don’t understand how my mum’s Gmail account was hacked

IMPORTANT: this is based on data I got from your link, but the server might implement some protection. For example, once it has sent its "silver bullet" against a victim, it might answer with a faked "silver bullet" to the same request, so that anyone...

What is /storage/emulated/0/?

/storage/emulated/0/Download is the actual path to the files. /sdcard/Download is a symlink to the actual path of /storage/emulated/0/Download However, the actual files are located in the filesystem in /data/media, which is then mounted to /storage/emulated/0...

How can I pass a command line argument into a shell script?

The shell command and any arguments to that command appear as numbered shell variables: $0 has the string value of the command itself, something like script, ./script, /home/user/bin/script or whatever. Any arguments appear as "$1", "$2", "$3" and so on. The...

What is pointer to string in C?

argv is an array of pointers pointing to zero terminated c-strings. I painted the following pretty picture to help you visualize something about the pointers. And here is a code example that shows you how an operating system would pass arguments to your...

How do I change the name of my Android device?

To change the hostname (device name) you have to use the terminal (as root): For Eclair (2.1): echo MYNAME > /proc/sys/kernel/hostname For Froyo (2.2): (works also on most 2.3) setprop net.hostname MYNAME Then restart your wi-fi. To see the change, type...

How does reverse SSH tunneling work?

I love explaining this kind of thing through visualization. 🙂 Think of your SSH connections as tubes. Big tubes. Normally, you'll reach through these tubes to run a shell on a remote computer. The shell runs in a virtual terminal (tty). But you know this part...

Difference between database vs user vs schema

In Oracle, users and schemas are essentially the same thing. You can consider that a user is the account you use to connect to a database, and a schema is the set of objects (tables, views, etc.) that belong to that account. See this post on Stack Overflow:...

What’s the output of this code written in java?

//if you're using Eclipse, press ctrl-shift-f to "beautify" your code and make it easier to read int arr[] = new int[3]; //create a new array containing 3 elements for (int i = 0; i < 3; i++) { arr[i] = i;//assign each successive value of i to an entry in...

How safe are password managers like LastPass?

We should distinguish between offline password managers (like Password Safe) and online password managers (like LastPass). Offline password managers carry relatively little risk. It is true that the saved passwords are a single point of failure. But then, your...

Can anyone tell me why this program go to infinite times?

while (i <= 2) { while (i > 0) { a = a + b; i--; <- out the inner while loop when i = 0 } printf("%d", a); i++; <- at here, the i==0 each time, so infinity loop } Because your nested loop always restores the value of i to 0, And 0 <= 2 is always...

How to conditionally do something if a command succeeded or failed

How to conditionally do something if a command succeeded or failed That's exactly what bash's if statement does: if command ; then echo "Command succeeded" else echo "Command failed" fi Adding information from comments: you don't need to use the [ ... ] syntax...

How to turn JSON array into Postgres array?

Postgres 9.4 or newer Obviously inspired by this post, Postgres 9.4 added the missing function(s): Thanks to Laurence Rowe for the patch and Andrew Dunstan for committing! json_array_elements_text(json) jsonb_array_elements_text(jsonb) To unnest the JSON array....