17

Is there a way to share my desktop Internet connection with my Android 2.2.1 using the phone data cable?

5
  • How do you mean? You're trying to share the connection from a tethered android phone?
    – Oli
    Jul 26, 2011 at 14:08
  • Nope, I want to share the internet connection of the computer with my android phone. So the other way around than tethering.
    – panmari
    Jul 26, 2011 at 14:21
  • Maybe you could explain exactly what you're trying to do. Why would you ever want to use your laptop's internet on your phone?
    – user606723
    Jul 26, 2011 at 17:03
  • 2
    @user606723 There are lots of reasons for wanting to do this - e.g. getting faster or cheaper internet service, wanting to capture or test MITM for packets from the phone, etc. The phone help notes that on windows this is done via "HTP sync", which you can download from HTC.com
    – nealmcb
    Aug 18, 2011 at 0:04
  • 2
    This is called Reverse Tethering.
    – BigSack
    Aug 15, 2012 at 6:13

2 Answers 2

11

Well, it can be done with rooted 2.2+ devices. It's not simple.

Before I start, you might just find it easier to buy a cheap USB Wifi dongle and share the connection to your phone through that. It's a much more simple procedure and doesn't require root on the phone.

But here's how to do it over USB:

  1. Put your phone in USB debugging mode (in settings → applications → usb). Plug the phone in.

  2. Then you need to turn on USB tethering on the phone. On my SGS2, this sits in Settings → Wireless and network → Tethering and portable hotspots.

    At this point, a new network device will be added to the computer (usb0).

  3. Fire off the following commands to bridge eth0 and your new USB connection.

    sudo apt-get install bridge-utils
    
    sudo brctl addbr br0
    
    for i in eth0 usb0; do
        sudo ifconfig $i 0.0.0.0
        sudo brctl addif br0 $i
    done
    
    sudo ifconfig br0 up
    sudo dhclient br0 # might take a few seconds
    
  4. Then load a terminal on your phone (or use the SDK adb shell) and fire off (as root):

    netcfg usb0 dhcp
    

To reverse it all:

for i in eth0 usb0 br0; do sudo ifconfig $i down; done
sudo brctl delbr br0
sudo ifconfig eth0 up
sudo dhclient eth0

To make things slightly easier there are a few Apps out there that do the phone side of things (ASProxy for example) but you still need a rooted 2.2 device. The computer side of things can be scripted. You could even hook into udev to fire these commands off when you plug the phone in (and destroy the bridge when you unplug it).

4
  • Thanks for your quick answer =) I'd wish, there was an easier way, though :(
    – panmari
    Jul 26, 2011 at 15:21
  • See this page for more details and comments on this kind of "reverse tethering": blog.mycila.com/2010/06/… I'm surprised it is so hard, and assume there is a simpler ubuntu-only method, presumably involving setting up ubuntu to be a router via FORWARD_IPV4=true etc.
    – nealmcb
    Aug 18, 2011 at 0:01
  • I don't get a usb0 interface appearing on my laptop (using 12.04) any ideas? May 15, 2012 at 12:33
  • This reverse tethering app and their help page helped me to successfully do this.
    – Anwar
    Feb 26, 2013 at 6:05
2

There are some old notes on Reverse USB Tethering with Android 2.2 with a Nexus One.

I've been planning to try this without rooting my HTC DHD.
It has an Internet Pass-through option which works great on Windows,
So, I wonder if this can be used on the same lines through Ubuntu...
Not tried yet -- would love to know of any first-hand experience.

Requirements from those notes are,

Android 2.2 (or an older version with a root tethering app)
ADB from Android SDK, or a rooted Android 2.2 with terminal in root mode

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .