Thursday, June 24, 2010

Reverse USB Tethering with Android 2.2

I've recently upgraded my Nexus One to Android 2.2, which include the USB Tethering option to connect a computer through the phone's Internet connection.

In my case, i want to do the opposite: when i don't have access to a wireless network, such as at work, i'd like to connect my phone to my computer and use my computer's Internet connection.

Here is below to do it manually. I hope I will have some time to develop a small app to automate all of this !

Requirements:
  • 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
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 intreface
# 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 !

-----------------------------------
Update 2010-07-21
-----------------------------------

I've tested on a Windows VM... Two problem occur:
  1. When we activate USB Tethering on the phone, the ADB connection is dropped: Windows does not seem to be able to handle both the network connection and the Android debug bridge like Linux.
  2. The Android interface that is installed does not seem to work like in Linux: we have no control about it and it only seems to work one-way... Even by setting manually the usb0 interface on the phone I wasn't able to activate the interface on Windows.
From what I see, it is related to a Windows issue, or a driver issue, since we do not seem to have the raw control we can have under Linux.

So... Windows users.... Perhaps it's time for you to switch to Ubuntu Linux ;-)

    142 comments:

    1. Awesome!
      Also might want to mention that for XP you need to dl the usb driver manually.
      http://www.android.com/tether

      ReplyDelete
    2. Yes, and you need Windows XP SP3 at least. The driver won't work on Windows XP SP2 (Code 10 error - cannot start driver) when installing.

      ReplyDelete
    3. Could someone help me out?

      I cant get this process to work. I'm unable to be tethered and be connect to shell via usb at the same time as the instructions suggest.

      ReplyDelete
    4. On Linux you can.

      On Windows, I don't know why but i was not able too. It seems the tethering feature disables the ADB support. So you have to use a terminal emulator on your phone.

      Also, on windows, on a network using DHCP, i didn't managed to make the usb0 interface get am address. I think it ha much more to deal about the bridging features or routing tables but I didn't checker further. Perhaps it works better with Internet Connection Sharing.

      ReplyDelete
    5. Hi,

      Can you please explain how can I bridge the usb port to the NIC in Windows? I got stuck with that :/

      ReplyDelete
    6. I'm using Windows 7. I shared my ethernet internet connection to the USB tether device.

      In console emulator on the phone I typed:
      ifconfig usb1 192.168.2.2 netmask 255.255.255.0 up
      route add default gw 192.168.2.1 dev usb1

      I can ping the gateway, I can also ping the web by IP address, eg 64.233.181.104 for google.com

      What I can't do is use the browser or ping by domain name. I tried:
      setprop net.usb1.dns1 192.168.2.1; and
      setprop net.dns1 192.168.2.1

      But with no luck, any ideas?

      ReplyDelete
    7. OK it is working now. After setting up ICS type in console emulator on your phone:
      ifconfig usb1 192.168.2.2 netmask 255.255.255.0 up
      route add default gw 192.168.2.1 dev usb1
      iptables -F
      iptables -F -t nat
      setprop net.dns1 8.8.8.8
      setprop "net.gprs.http-proxy" ""

      Hope it works for everyone else. GL HF.

      ReplyDelete
    8. Type-o, change the usb1 to usb0, sorry.

      ReplyDelete
    9. Nice ! It's quite a good news that it works with ICS. For your issue, I can't verify right now but since it seems to be a DNS issue, did you try a
      cat /etc/resolv.conf to see if your dns servers are there ? Also, i know that my phone has a dnsmasq daemon running: probably it can be reconfigured or stopped to test...

      ReplyDelete
    10. I worked out the DNS issue. See my second comment :)

      ReplyDelete
    11. What I Have found

      XP
      ICS wont work
      Bridge Works sometimes

      Windows 7
      ICS works
      Bridge Fails

      Any pointers?

      ReplyDelete
    12. I tried this in my rooted Nexus One with Ubuntu.

      There is no response when I run the statement on the phone.
      netcfg usb0 dhcp

      Any help ?

      ReplyDelete
    13. I am not able to get dhcp for android working, it does not returns an address.
      I have tried to do it manually, but I have got no success. Is there some way around ?

      ReplyDelete
    14. Hi,

      If you read the comments, some users made it work on windows. I know it works on Ubuntu by just issuing the commands on the blog article. There is no extra thing to do and it works with a standard ubuntu setup.

      Probably you should try more and at least post some error codes, messages and exactly what you did / typed so that we can help you.

      But please don't just write "it doesn't work for me blablabla": these comments are completely useless and don't bring any information ;-)

      ReplyDelete
    15. I tried to same steps as mentioned till step 3.
      When I ran Step 4, there was no response, the command never quit. I had to break it using 'Ctrl + C'.

      My laptop connects to the network with IP 10.1.36.187.
      So I tried manually setting the IP and the gateway using

      ipconfig usb0 10.1.36.189 netmask 255.255.255.0
      busybox route add default gw 10.1.36.1

      It responds to the ping statement to 10.1.36.187, but it does not to 10.1.36.1 ( The gateway )

      ReplyDelete
    16. Hi,

      In your case, you does not seems to be on a dhcp-enabled network so the command in step 4 is not relevant for you.

      => You have to configure your android usb0 interface manually, plus also the DNS servers.

      Perhaps the commands on the comment above you could help you:

      ifconfig usb0 10.1.36.189 netmask 255.255.255.0 up
      route add default gw 10.1.36.1 dev usb0
      setprop net.dns1

      and if you are not behind a proxy:

      setprop "net.gprs.http-proxy" ""

      otherwise specify its address. Also try this:

      iptables -F
      iptables -F -t nat

      ReplyDelete
    17. The command

      iptables -F
      gives the following error
      getsockopt for multiport failed strangely: No such file or directory
      getsockopt for multiport failed strangely: No such file or directory

      I did run each of the commands, but still unable ping. It just says destination host unreachable

      ReplyDelete
    18. My network is dhcp enabled but I guess since the usb0 network interface mac address is not of type 00:xx:xx:xx:xx:xx It cannot acquire a network.

      I even tried changing the mac address of usb0 but still the dhcp didn't work.

      ReplyDelete
    19. Finally I got the solution.

      In my network only registered users were given IP through dhcp. I found a way out and now I am able to ping the sites through the terminal.

      But still I am not able to run the internet on applications like browser, gtalk. They say no network available.
      Is there something else which I am missing?

      ReplyDelete
    20. Does the phone needs be rooted ?

      Is this possible with 2.1 also ? .If this needs anything different ,could you list please .Thanks.

      ReplyDelete
    21. I followed the instructions, on terminal I can ping. However most applications don't connect to the internet. they say that there is no internet connection. I thing it is because we don't connected to internet by "legal" ways.
      How can we solve it?

      ReplyDelete
    22. kunal I've got the same errors with iptables -F, what is the solution you found?

      ReplyDelete
    23. I did all the steps and it looks like to me its a little hit or miss when it comes to what apps work and which ones don't. Like Foursquare works. But not many other apps. Is there any way to fix this?

      ReplyDelete
    24. After giving the command
      ./adb shell netcfg usb0 dhcp

      I am getting the error:
      action 'dhcp' failed (Permission denied)

      Anyone has any idea what am I missing....

      ReplyDelete
    25. If you enable USB tethering, you cannot execute adb shell commands from your computer.

      This article, at best, is a broken set of instructions.

      ReplyDelete
    26. ...to those who got this working:

      when in 'reverse tether mode' it seems android needs to be convinced that it has a 'proper' network connection.

      log:
      D/ConnectivityService( 166): getMobileDataEnabled returning true
      D/ConnectivityService( 166): special network not available

      ...otherwise some services, e.g. contacts sync, don't work. anyone know a solution to this?

      ReplyDelete
    27. Any chance to port this to a bluetooth interface?
      I'd really love to connect my HTC to another bluetooth-internet-sharing mobile phone.

      Also willing to pay for an app doing this!

      Thanks

      ReplyDelete
    28. Same as everyone else. Running "su
      netcfg usb0 dhcp" does not respond on the phone.

      ReplyDelete
    29. Rosetta Stone Spanish Spain
      Great precise info, I've been searching on this topic for a while. Bookmarked and recommended!

      ReplyDelete
    30. Aw, this was a really quality post. In theory I'd like to write like this too – taking time and real effort to make a good article… but what can I say… I procrastinate alot and never seem to get something done.
      office activation

      ReplyDelete
    31. Works fine with Linux Mandriva ! Thanks !

      ReplyDelete
    32. Aw, this was a really quality post. In theory I'd like to write like this too – taking time and real effort to make a good article… but what can I say… I procrastinate alot and never seem to get something done.
      office product key

      ReplyDelete
    33. Nice, works fine on my rooted Hero 2.2. Even after taking it out of the cradle and putting it back in :D Its my old phone so now i serves as a Facebook notifier on my desktop, haha. Also no wifi here.

      ReplyDelete
    34. Hi I am having LG GT540 with Android 2.1
      i want to do reverse tether. I am having a PC with XP XP3 any body can tell me how to do reverse tether

      ReplyDelete
    35. When my phone (HTC Wildfire w/ Android 2.2) is in USB-Tethering-mode I cannot execute any adb-commands.
      When I connect the phone in mass-storage-mode I can execute adb, but I get the message 'permission denied' when I try './adb shell netcfg usb0 dhcp'.
      Any ideas?

      ReplyDelete
    36. thx, it work for me.

      i can go to marklet and see all the apps, but i cant download the app.

      have some1 same issue?

      ReplyDelete
    37. I tried the instructions but it didn't work. when I type the netcfg usb0 dhcp on my rooted phone (galaxy S) it just 'hangs' there, as in i never get the prompt back..
      I also noticed that after typing ifup br0 and dhclient br0, i can't browse on my laptop (opensuse 11.2) any ideas?

      ReplyDelete
    38. I tried this with my Win7x64 PC, and my rooted Droid's terminal emulator locks up on the "netcfg usb0 dhcp" command. Is there something else I need to be doing?

      ReplyDelete
    39. Hello everyone!
      Please help me out with my Issue.
      I am very new to android platform. This is my new android phone Samsung GT-I5510> It runs Android 2.2 Froyo. I donot know how to root my android phone and How do i execute those above said commands in the android console. I understand that some commands are for Windows command prompt. But some i think are for Android console. Where can i get that console, How? and if i downlaod Andoid SDK, how do i use it to connect to my PC? Kindly help.
      I am a newbee, so apology for silly small questions!
      Waiting for the answer! ;-)

      ReplyDelete
    40. Looks great!

      Still having the issue, that the internet connection of my PC breaks down, when the tethering is established (and works inside the android)!

      Have to use static-ip-method (Rugga post).

      Is there any way to keep the PC-internet connection alive?

      Thanks,
      Guntram

      ReplyDelete
    41. On Ubuntu 10.10 adb does not see any devices after enabling tethering on device. If you disable tethering, adb is seeing the device again.

      So you cannot ./adb shell netcfg usb0 dhcp.

      ReplyDelete
    42. I am also seeing the described problem with locking network connection on opensuse 11.3 as well as the topic regarding the adb commands.

      It would be really great, if I'd find a solution in order to be able to use my Linux-PCs internet connection via USB

      ReplyDelete
    43. You are the man! reverse tethering worked like a charm on my Moto Droid!

      ReplyDelete
    44. Please, can someone who managed to make it work specify what Linux distro are they using?

      ReplyDelete
    45. never thought about bridging before :p....initially when i bridged two connection in windows xp, both interface took same ip address and did not work....later i did "dhcpcd usb0" on phone..it detected the problem and gave a new unique ip...problem solved!

      ReplyDelete
    46. Is there any simple way to do it without become an androïd Guru ?

      I just want it to work and don't want to learn shell... Where do i click ?

      ReplyDelete
    47. The topmost right button which says close.

      ReplyDelete
    48. if i input adb shell netcfg usb0 dhcp on my pc i get the error "action 'dhcp' failed

      and if i input netcfg usb0 dhcp on my phone i get "action 'dhcp' failed (permission denied)

      any ideas?

      ReplyDelete
    49. That's a shame that Android doesn't support reverse tethering natively when Windows Mobile does it for many years now!

      ReplyDelete
    50. I have the same problem several people here noticed, that is some application work and some don't after creating the connection.

      For me the browser, Gmail and Pulse at least work but Gtalk and Skype don't.

      There must be some setting that needs to be done that is missing. I looked at "net.gprs.local-ip" and set it to the usb0 ip and it doesn't help. I also set some dhcp.* setting to be identical to the ones I set manually (dhcp didn't work for me) but still nothing.

      Maybe somebody that knows more about network settings on android can help with suggestions? Or a link to android network settings help?

      ReplyDelete
    51. Know of a tethering application on the market that this guide works with?

      I am a sad owner of Sony Ericsson Xperia x10 mini and am stuck at Android 2.1 probably forever, so I need a good tethering app for this to work :(

      ReplyDelete
    52. It worked on my rooted Motorola Defy (Android 2.1) without USB tethering app. I have Windows Vista 32bit and I used ICS.

      ReplyDelete
    53. I am getting the error- action 'dhcp' failed (Permission denied)
      when i execute- netcfg usb0 dhcp

      Also this link which helped many is not available any more:- http://www.rosettastonelearning.com/rosetta-stone-spanish-spain-c-6.html

      Cud any1 which found the above link useful.. pl repost the contents...

      ReplyDelete
    54. Hi there, I like the promise of this article, but before I start I want to know what I'm getting into.
      What do I have to do to execute "On Windows computer, bridge the 2 network interfaces". What does that mean?

      ReplyDelete
    55. @March 25, 2011 4:44 AM
      are you able to ping your DNS server ?
      try to ping it otherwise you have to check the route or set usb0 manually

      Anyone knows how to use rev_teth with android market ?

      ReplyDelete
    56. Thank you.......The first time i got an error saying permission denied. But after rooting my android phone the steps worked fine.Now I can get to the android market and download stuffs using my pc internet connection.... This is cool....... I am not very good at this networking stuff and all.But you made it pretty simple. I just wanted to know whether there is any security issues in bridging to a public network?????????
      Thanks again.........

      ReplyDelete
    57. I can't download from android market. Downloading is paused all the time. What should i do????????????

      ReplyDelete
    58. Hi

      I'm running windows 7, and have a Samsung Galaxy Fit S5670 running android 2.2. I tried the mentioned steps, but netcfg usb0 dhcp results in timer expired.
      So I went throught the post and tried Rugga's suggestion, but can't ping anything. I've tried bridging both my networks, as well as ICS, but both don't seem to work.I would love it if somebody could help me out on this.

      A few questions that spring to my mind:
      1. The network adapters are set to "obtain IP Address automatically", should I give them a static IP Address?
      2. Should I use ICS, or should I Bridge the network adapters.
      3. Curently I have, at my computer:

      Ethernet adapter Local Area Connection 4: (This is the phone's network adapter)

      IPv4 Address. . . . . . . . . . . : 192.168.42.207
      Subnet Mask . . . . . . . . . . . : 255.255.255.0
      Default Gateway . . . . . . . . . : 192.168.42.129

      Ethernet adapter Local Area Connection 2: (This is the network adapter connected to the internet)

      IPv4 Address. . . . . . . . . . . : 192.168.1.2
      Subnet Mask . . . . . . . . . . . : 255.255.255.0
      Default Gateway . . . . . . . . . : 192.168.1.1

      At the android terminal, using ifconfig usb0, I get:

      ip 192.168.1.3 mask 255.255.255.0 flasgs [up brodcast multicast]
      so what goes where in the android terminal commands? Any help would be appreciated.

      ReplyDelete
    59. do you have now an app for reverse usb tether?
      i didn`t understand this how to.
      i hope you have an app!!
      Sry for bad english!

      ReplyDelete
    60. I finally got it to work, might be worth mentioning that the command "netcfg usb0 dhcp" took a little while to finish

      ReplyDelete
    61. where do i get this app?

      "Android 2.2 (or an older version with a root tethering app)"

      can this be downloaded on the android market? if so, please tell the name of the app. much thanks

      ReplyDelete
    62. I made a bash script that toggles this with your excellent tips for reverse tethering. Thanks! This can be bound to a key with xbindkeys. I have used it to connect and disconnect my Android.

      #!/bin/bash

      bridge_status=`cat .bridge_status.txt`
      if [ "$bridge_status" == "down" ]
      then
      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
      echo "up" > .bridge_status.txt
      elif [ "$bridge_status" == "up" ]
      then
      sudo ifconfig eth0 down
      sudo ifconfig usb0 down
      sudo ifconfig br0 down
      sudo brctl delbr br0
      sudo ifconfig eth0 up
      sudo dhclient eth0
      echo "down" > .bridge_status.txt
      else
      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
      echo "up" > .bridge_status.txt
      fi

      ReplyDelete
    63. I have an optimus one phone,
      its not rooted yet.In ubuntu I tried
      to run after bridging:

      ./adb shell netcfg usb0 dhcp
      and returns
      action 'dhcp' failed (Permission denied)

      Also internet connection is disabled when
      bridging is done(even after setting static ip in etc/network/interfaces).
      Please help me guys...

      ReplyDelete
    64. @rQ have the same phone, same issue, to resolve, run the command in su.

      It worked for me.

      ReplyDelete
    65. This is Kiran. Any updates to make it work for Windows PC.

      ReplyDelete
    66. its working on my rooted G1 running custom 2.2.1 ROM.

      All I did was ICS on my Windows 7 PC to the NDIS connection created when selected tether on android.

      In terminal emulator -
      su
      netcfg usb0 dhcp

      *and wait for a short while*

      certain apps are not connecting to the net like whatsapp, market..

      apps connected are applanet, msnbc and other news apps.

      no idea why's this happening

      ReplyDelete
    67. Any chance to create a script for reverse tethering and a script for back to the phone own tethering?

      ReplyDelete
    68. Hi, Have you been able to make the program to automate this process? It will really help a lot of people/noobs

      ReplyDelete
    69. I have a little problem here. When i make a bridge my internet connection on PC doesn't work at all (neither on my droid). I get internet via a static IP adress and a gateway, i don't have a DHCP, so maby this is why internet doesn't work. If i am right with this, how do i set my bridge to use a static ip, gateway, mask..? Running Ubutnu, but had same situation on windows.

      ReplyDelete
    70. Have ubuntu, android 2.2.1,achived to make the brigde and the two nets but it seems the usb0 cannot take a ip from dhcp(tried both ways from pc terminal and rooted terminal) so my phone ideos has no ip.

      ReplyDelete
    71. Rugga.. Awsome Work. You are a Star.
      Its working
      just to point out
      dns and default gateway IP's should be the one assigned to NDIS adapter on PC. Sometimes its not 192.168.0.1

      Have you managed to sort-out issue with apps like not able to download game data or market apps.

      Ashigro@gmail.com

      ReplyDelete
    72. Wow that was odd. I just wrote an very long comment but after I clicked submit my comment didn’t appear. Grrrr… well I’m not writing all that over again. Anyways, just wanted to say wonderful blog!
      Web hosting

      ReplyDelete
    73. The connection seems to be active and i can surf the internet. But i can't seem to download as such (explicitly downloading items), from market or non-market sites... It just stays in the "Waiting for data connection.. " state. Please help, Thanks in advance.

      ReplyDelete
    74. Regarding your update on 2010-07-21; it's not a windows issue. I used to have an LG phone with Froyo, and I was able reverse tether and Usb debug at the same time. But now I got Galaxy S with Froyo and I can no longer do it, plus tethering and Usb debugging don't work simultaneously on this device which sucks.

      Someone should write an app to do this.

      ReplyDelete
    75. Some one did ...

      Thierry Parent has put up a working solution here ...

      [URL="http://www.codeproject.com/KB/android/UsbPortForwarding.aspx"]http://www.codeproject.com/KB/android/UsbPortForwarding.aspx[/URL]

      Worked great for me !

      Cheers,
      Vikram.

      ReplyDelete
    76. Well I did everything but when I type "adb shell netcfg usb0 dhcp"

      Or

      "su
      netcfg usb0 dhcp"

      Nothing happens and on the PC the device is not found :(

      ReplyDelete
    77. I understood what to do but not how to. Which 2 connections do i have to bridge?
      And when i select usb tethering on my android(galaxy fit)i get a new network on windows saying local area network 8.
      Please someone make an app for all this!!
      Please send it here
      abizerl123@gmail.com

      ReplyDelete
    78. I did everything as you said. But i can't get it to work. Mine is a rooted phone. I am able to tether my phone only when my packet data is disabled. But when i disable the packet data and run all the commands you said, then i can't access internet ( all the commands worked fine without a single error message). It says network settings needs to be changed. Please help !!!!!!!
      Recently I upgraded my firmware to gingerbread. But when I came to know that reverse tethering doesn't work in gingerbread I switched back to froyo.......

      ReplyDelete
    79. I have samsung galaxy pop ( GT-S5570),not rooted.
      1) How do i install USB driver from Android SDK. it says "not supported".
      2) How do I "bridge the 2 network interfaces" on windows XP :STEP 3 ??
      3) ALSO , I did not understand STEP 4??
      plzz help :-(

      ReplyDelete
    80. Can't get step 4 to work "adb shell netcfg usb0 dhcp" just freezes the terminal same as when I do su
      netcfg usb0 dhcp on the phone. All other steps worked fine.

      ReplyDelete
    81. Can please also mention how to bridge networks in windows.

      Mohneesh
      Software Developer

      ReplyDelete
    82. "how to bridge networks in windows"

      http://www.windowsnetworking.com/articles_tutorials/wxpbrdge.html

      ReplyDelete
    83. I finally got it working on my XP SP3. I am not an expert, but trial and error worked. I did not use Bridging, but used ICS. I used root access.

      First connect to internet on PC and enable ICS. If you have a USB dial-up modem, it may be easy to enable ICS.

      If you have a router, ICS may fail to enable as most routers use 192.168.0.x range. ICS needs to use 192.168.0.x range. You will need to change the router IP(and DHCP range) to 192.168.1.x from 192.168.0.x range. Then repair the connection to get the new IP. Now try the get ICS enabled.

      With ICS enabled, connect the mobile to the PC. Switch on USB tethering. A new "Local Area connection" should appear in Network Connections. For the new mobile connection, set the IP address to 192.168.2.1 netmask 255.255.255.0

      Execute the below on a terminal emulator on the mobile. I made a shell script with #!/system/bin/sh on the first line and executed it. Also I ran the below commands as root.
      ifconfig usb0 192.168.2.2 netmask 255.255.255.0 up
      route add default gw 192.168.2.1 dev usb0
      iptables -F
      iptables -F -t nat
      setprop net.dns1 8.8.8.8
      setprop "net.gprs.http-proxy" ""

      Check if internet works(use browser) on the mobile without closing the terminal emulator. I think I needed to execute “netcfg usb0 dhcp” when I used the router as the router is a DHCP server, not for my USB modem.

      I could not get EVERYTHING working. Browser, youtube, google map, google search, email(not gmail) works. Google specific apps like gmail do not seem to work. Android market works, but downloads do not happen.

      Good luck,

      ReplyDelete
    84. continuation to my previous post...
      Gmail can work, but use it as a email and not gmail specific app.

      ReplyDelete
    85. Isnt there a script or bat file to make all this command.i dont understand, developers doing everything with android phones but cant do this even though htc phones have this feature.is it so hard to find it?

      ReplyDelete
    86. SuPeRfLyiN, You could copy the commands to a file and type sh if you have a terminal emulator. I speak from XP point of view only. You may need a bit of unix knowledge to use the Android OS.

      ReplyDelete
    87. Works for HTC Wildfire with Cyanogenmod 7.1-RC1 connected to Ubuntu 9.10 in VMware Player on Windows XP SP3 host.

      thanks!

      ReplyDelete
    88. After running the following command:

      sudo ./adb shell netcfg usb0 dhcp or
      ./adb shell netcfg usb0 dhcp

      I get:

      action 'dhcp' failed (Permission denied)

      I think this is because the phone needs to be rooted, aka it is not possible to have reverse-tethering without rooting, at least not on Samsung Galaxy. If I'm wrong (and I hope so), please correct me..
      Luca

      ReplyDelete
    89. So weird. Yesterday it was working perfectly. I was able to browse the internet using the browser, I could install market apps, ... but now I get stuck at the "netcfg usb0 dhcp". I get the error "action dhcp failed (Timer expired)" after a long time. What do I do wrong ? I did everything I did yesterday again...

      ReplyDelete
    90. Whoops ! Never mind what I just said. If for some reason the tethering doesn't work anymore, just undo the sharing. Then re-share it and check if all checkboxes are ticked in advanced settings...

      ReplyDelete
    91. https://market.android.com/details?id=service.tracetool&feature=search_result

      "With this solution, you can surf on your mobile (using the internet connection on your PC) through the USB tunnel AND a proxy."

      ReplyDelete
    92. i am behind proxy connection windows 7 bridged
      ifconfig usb0 10.10.48.243 netmask 255.255.255.0 up
      route add default gw 10.10.48.1 dev usb0
      iptables -F
      iptables -F -t nat
      setprop net.dns1 8.8.8.8
      setprop "net.gprs.http-proxy" "10.10.48.133:8080"

      it is not working for me

      ReplyDelete
    93. https://market.android.com/details?id=service.tracetool&feature=search_result

      "With this solution, you can surf on your mobile (using the internet connection on your PC) through the USB tunnel AND a proxy."

      Do you need to use a Windows PC (because you have to install a Windows application on the host side) or can it also be a Linux host?

      ReplyDelete
    94. I recently realized that this feature comes default in the new 2.3 OTB HTC phones. They just call it "Internet pass-through".

      No root. No bridging required.

      ReplyDelete
    95. I have a Samsung B7610 OmniaPro with Android Froyo Beta installed (that is the only working porting for my phone). Now, the problem is that, despite 2.2.2 version, there's no "usb tethering" menu to activate, so i cannot get ubuntu tu see the "usb0".
      The only solution is to run an app that would make ubuntu detect some network card. I've tried several apps and the only apk that can do this is EasyTether, infact when i run it a new "Easytether0" network card is found. So I follow the instruction using easytether0 instead of usb0, and all goes fine until I need to use the final adb command, since easytether cannot work with adb running. There's the second option, i.e. running the command from the terminal on phone, but if i run netcfg i don't see any easytether0 network card, nor usb0, so i have to stop in the last step :(
      So, my questions are:
      1) is there a way to activate the usb tethering option directly on settings menu like other froyos? this would be the perfect solution...
      2) is there any app that creates a usb0 or some other network card visible by adb or by netcfg on phone?
      Please help

      ReplyDelete
    96. I have successfully reverse tethered my goggle nexus s. Now what i want is to create a wifi hotspot with this. When i connect using my laptop to the hotspot it shows no Internet access.How can i make it to work? any suggestions?

      ReplyDelete
    97. I followed the instructions and nothing seems to happen in my terminal after su netcfg usb0 dhcp step.

      Is it possible for someone to make a video of the entire process on ubuntu?

      I'm on TMobile g2x. Android 2.3.4.

      ReplyDelete
    98. has anyone figured out how to download market apps

      ReplyDelete
    99. Ok, i just did it, and it didn't work right away. Two things that I had to do (this is in windows 7) was that when you type in netcfg usb0 dhcp, it didn't work for me so I tried usb1 instead, and that worked. Also, I didn't bridge the connection between the two adapters, I just went to my ethernet connection and clicked properties, sharing, and shared the internet with the other network adapter (which is the phone is tethering mode). I hope this helps some people.

      ReplyDelete
    100. You can try Port Fowarding. I think it's very easy but work.
      http://www.codeproject.com/kb/android/usbportforwarding.aspx

      ReplyDelete
    101. Okay, I've figured most things out but get host unreachable when I ping my gateway. My network is not dhcp enabled I think. Is there a way to manually configure things to make it work?

      ReplyDelete
    102. I have executed such things and perform well!Thanks

      ReplyDelete
    103. Want to connect Android mobile to laptop internet by USB cable


      Hello,

      Do you have any definitive reply about connecting your phone to internet through USB ?

      My laptop is using a Wifi that needs USER and PASSWORD to login, and I cannot login on laptop and phone at the same time (only one user can be connected).

      Thanks.

      ReplyDelete
    104. Thank you Nadan, greatly appreciated!!!
      Jakub

      ReplyDelete
    105. Nandan - your post was fundamental, thank you very much...

      ReplyDelete
    106. i hope someone comes up with an apk and a server which does everything for us

      ReplyDelete
    107. Hi,

      I'm not able to set up a bridge.
      I have to do something like:

      ip addr flush dev

      as explained in [https://help.ubuntu.com/community/NetworkConnectionBridge].
      Is suppose that is the name of the interface where I must connect my android-phone.
      Is "usb0" the standard name of ?
      How can I get the right name of the usb interface?

      Thanks.

      ReplyDelete
    108. Pity "netcfg usb0 dhcp" doesn't automatically set the dns: just as well you can do it with setprop

      ReplyDelete
    109. Hi,
      I'm a new Ubuntu 11.10 user. Try to conect SE Xperia X10 (Android 2.2) connect to Internet via desktop I/net connection. I have a problem with Step 4 (From your computer, execute:
      ./adb shell netcfg usb0 dhcp) / I get a response:

      -bash: /adb: No such file or directory

      what is wrong? Any ideas? Thanks

      ReplyDelete
    110. for me it works with win xp:

      just set a share connection, tick 2 boxes in advance card and then (IMPORTANT)open settings within "sharing internet connection" and tick all the boxes inside (or maybe just a DHCP)

      then run this command: netcfg usb0 dhcp and you should be done.Works on htc pure :P

      ReplyDelete
    111. This one worked for me on windows 7. Even market works following the second post in that thread. :)

      http://forum.xda-developers.com/showthread.php?t=1172528

      I'm on T-Mobile g2x and not wildfire for which the thread in the above link originally was. So, I assume it works for all androids.

      Also, didn't have to go through netcfg command which never worked for me for some reason.

      Every app, market and browser(even Opera Mini!) works with this method.

      ReplyDelete
    112. Dear All Experts...

      on the starting of this blog...author said..its work with ubuntu and android'


      but in my case
      i have ubuntu latest version and android 2.2 foryo but i cant enable internet of my pc in my mobile via reverse tethering....

      pls kindly help me to resolve this issue

      ReplyDelete
    113. For those who notice some apps work and some don't, I thought this may apply. I have not read this all thoroughly, so please do so yourself before taking my advice :)

      ReplyDelete
    114. Lost the link somehow.......

      http://stackoverflow.com/questions/7626564/android-usb-reverse-tethering-how-to-fool-the-apps

      ReplyDelete
    115. I have a rooted Xoom on which I have disabled all WiFi connections and successfully enabled reverse USB tethering to my Ubuntu box. However, every time I reboot the Xoom, I lose all settings. I need it to come up each time with WiFi disabled and USB tethering on. I am currently modifying the ROM I am using. I added a start up script with the config/route commands and have modified the Settings.db table (setting system.airplane_mode_on to 1 and secure.wifi_on to 0). However, I cannot for the life of me figure out how to enable USB tethering automatically at boot up. Does anyone know what table entry or other setting needs to be modified to do this?

      ReplyDelete
    116. what about android 2.3.4 ..would work ?
      i tried it when my android was 2.1 .. and it worked perfect for usb and wifi .. just change code
      su
      netcfg wlan1 dhcp //*(that for wifi)
      netcfg usb0 dhcp //*(that for usb)
      for wifi .. you need wireless card on your pc ..
      otherwise.. not work
      you could write only netcfg to know which wlan0 or wlan1 that work you will see there is ip for it in list that appear..

      question now why not work when i upgrade my android .. i have rooted it after upgrand and sure adb work and when write in terminal emulator
      the code the "#" symbol appear .. but no internet :(

      ReplyDelete
    117. Does it supposed to work with a non-rooted phone??
      Because when I type " adb shell netcfg usb0 dhcp " it gives " action 'dhcp' failed (Permission denied) "

      Do I need to root my Xperia Neo ?? Or it's just because something went wrong?



      ps: sorry about my bad english im french

      ReplyDelete
    118. thanks a lot, it's working for me. I use HD2 T-mobile with Typhoon CM7 android 2.3.7 and it works but download from Market doesn't work. i used ICS and when i checked all options in setting in ICS it gets work. and use command "netcfg useb0 dhcp"

      ReplyDelete
    119. is there anyway to activate full access to internet with this way, because no syncing, no downloading, just browsing, any ideas???

      ReplyDelete
    120. Well then tell us

      ReplyDelete
    121. Alternativelly, you can use NAT forwarding/masquerading on the GNU/Linux box (it's easier and compatible with WiFi lan):

      First, after enabling tethering on your Android Phone, set up the link

      # sudo ifconfig usb0 up
      # sudo dhclient usb0

      Now check the IP given to your usb0 device, you'll need it:

      # sudo ip addr show dev usb0

      In my case, I've got 192.168.42.41. And now you'll have to add one rule to the iptables:

      # sudo iptables -t nat -A POSTROUTING -s 192.168.42.0/24 ! -d 192.168.42.0/24 -j MASQUERADE

      In your phone, you have to set up also the default route and maybe your DNS settings (recall the IP that usb0 were given):

      # ip route add default via 192.168.42.41

      That's all... Now, your phone must have Internet full access

      ReplyDelete
    122. when i enable usb tethering on my phone adb no longer recognizes my device anymore. if i turn it off then adb see my device ive seen other people post having the same problem but i havent seen anyone reply with a solution

      ReplyDelete
    123. There's a new app called ReverseTehter, that allows you to do just that (access your computer's connection via usb). It doesn't require any extra software, or windows installations, or ADB/debugging, or tech savviness, and your connection looks like 3G so that all your apps work seamlessly including Market, Downloads and Talk. it requires a rooted device.

      See this video to learn how to use it: http://www.youtube.com/watch?v=iAkUSMyTpcA

      ReplyDelete
      Replies
      1. Sadly its demo has the trial stipulation that it only works between certain hours, however it gives that fail message OUTSIDE of those hours, and the devs aren't responding to email about it. Frustrating because this might have been an easy solution.

        Delete
    124. Tethering works find for me with CyanogenMod 6.0 RC1 on a HTC Desire (myTouch) and Linux.

      On my Linux box,

      I created /etc/udev/rules.d/52-tethering-stuart.rules with
      SUBSYSTEM=="net", ATTRS{idVendor}=="0bb4", ATTRS{idProduct}=="0ffc", NAME="usb-mytouch"
      I added the following to /etc/network/interfaces
      allow-hotplug usb-mytouch
      iface usb-mytouch inet dhcp
      up iptables -I INPUT -i $IFACE -j ACCEPT
      down iptables -D INPUT -i $IFACE -j ACCEPT
      up echo 1 > /proc/sys/net/ipv4/ip_forward
      up iptables -I POSTROUTING -t nat -s $IF_ADDRESS/24 -j MASQUERADE
      post-down iptables -D POSTROUTING -t nat -s $IF_ADDRESS/24 -j MASQUERADE
      up iptables -I FORWARD -i $IFACE -s $IF_ADDRESS/24 -j ACCEPT
      post-down iptables -D FORWARD -i $IFACE -s $IF_ADDRESS/24 -j ACCEPT
      up iptables -I FORWARD -o $IFACE -d $IF_ADDRESS/24 -j ACCEPT
      post-down iptables -D FORWARD -o $IFACE -d $IF_ADDRESS/24 -j ACCEPT

      on the Android phone I switched the tethering on and then via adb shell did
      route add default gw 192.168.42.162 dev usb0
      setprop net.dns1 212.27.40.241
      The 192.168.42.162 is the address that my phone gave to the usb-mytouch interface on my Linux box and 212.27.40.241 is the address of my name server (/etc/resolv.conf). I had to convince dhclient usb-mytouch not to overwrite the name server from my ISP by adding to /etc/dhcp/dhclient.conf
      interface "usb-mytouch"
      {
      supersede domain-name "";
      supersede domain-name-servers "";
      supersede domain-search "local.foo";
      }

      ReplyDelete
    125. ReverseTehter. A+++
      Thanks Anonymous so much. It's fantastic. I can even use the Market to download apps.

      ReplyDelete
    126. I'd tried that usb tethering before. It really works but my phone easily get drained. But this one is different thing, the reverse of what I know. It's a great information. Thanks.

      ReplyDelete
    127. I cant get it work :
      cutiyar@cutiyar:~$ adb shell netcfg usb0 dhcp
      action 'dhcp' failed (No such device)
      cutiyar@cutiyar:~$

      thanks.

      ReplyDelete
    128. Thanks for the detailed write-up. Got it working with Ubuntu and GB as well as ICS on my Nexus One. However, I want to go a step further and share my PC's internet connection with other phones in the vicinity over WiFi. However, simply enabling the WiFi HotSpot on my reverse usb tethered Nexus One doesn't help. Any ideas???

      ReplyDelete
    129. hey i tried it in ubuntu with my ROOTED Galaxy ACe 2.3.3, but din't work...can you plss help me!!

      in my phone's emulator it is howing action 'dhcp' failed!

      ReplyDelete
      Replies
      1. It is likely that the USB interface name is different on your device. On my SGS2, it is called rndis0 instead of usb0. To find out, unplug the USB cable, run netcfg and note the interfaces. Then plug the cable, activate tethering and run netcfg again. A new interface should show up, which should be the USB interface for your device.
        The command seemed to hang on my phone even with the right name though...

        Delete
    130. there is a free app in the market called "USB reverse tethering".
      Your phone has to be rooted and with USB debugging enabled.

      ReplyDelete
    131. vmware + xp + htc sync works fine for unrooted phones

      ReplyDelete
    132. Simple reverse tethering:
      http://eduyoshida.com.br/blog/2012/07/usar-a-internet-do-pc-no-android-reverse-tethering/

      ReplyDelete
    133. Thanks for such a valuable information. I am new to Android(once a iPhone user). I am learning about Android. I find many links on your blog regarding tethering. I will check through all these and see if it works.

      ReplyDelete
    134. WARNING: ubuntu users: this may not work and may kill your standard connection like it did mine.
      Also: you need to install something first.
      My log:

      simon@Poseidon:~$ sudo ifconfig eth0 0.0.0.0
      simon@Poseidon:~$ sudo ifconfig usb0 0.0.0.0
      simon@Poseidon:~$ sudo brctl addbr br0
      sudo: brctl: command not found [added it by searching for 'brctl' in ubuntu software centre. This should be mentioned at the top]
      simon@Poseidon:~$ sudo brctl addbr br0
      simon@Poseidon:~$ sudo brctl addif br0 eth0
      simon@Poseidon:~$ sudo brctl addif br0 usb0
      simon@Poseidon:~$ sudo ifconfig br0 up
      simon@Poseidon:~$ sudo dhclient br0
      Rather than invoking init scripts through /etc/init.d, use the service(8)
      utility, e.g. service smbd reload

      Since the script you are attempting to invoke has been converted to an
      Upstart job, you may also use the reload(8) utility, e.g. reload smbd

      [wasn't sure if this fail message was meant it hadn't worked or if this is normal so i tried the next step just in case]

      simon@Poseidon:~$ ./adb shell netcfg usb0 dhcp
      bash: ./adb: No such file or directory

      [i already looked for it & it wasn't there]
      [tried the idea in Anonymous' 26/2/2012 post]

      simon@Poseidon:~$ sudo ifconfig usb0 up
      simon@Poseidon:~$ sudo dhclient usb0
      Rather than invoking init scripts through /etc/init.d, use the service(8)
      utility, e.g. service smbd reload

      Since the script you are attempting to invoke has been converted to an
      Upstart job, you may also use the reload(8) utility, e.g. reload smbd
      RTNETLINK answers: File exists
      simon@Poseidon:~$ sudo ip addr show dev usb0
      5: usb0: mtu 1500 qdisc pfifo_fast master br0 state UNKNOWN qlen 1000
      link/ether c6:52:ca:a7:74:a9 brd ff:ff:ff:ff:ff:ff
      inet 192.168.42.253/24 brd 192.168.42.255 scope global usb0
      inet6 [blahblah] scope link
      valid_lft forever preferred_lft forever
      simon@Poseidon:~$ sudo iptables -t nat -A POSTROUTING -s 192.168.42.0/24 ! -d 192.168.42.0/24 -j MASQUERADE
      simon@Poseidon:~$ ip route add default via 192.168.42.41
      RTNETLINK answers: Operation not permitted
      simon@Poseidon:~$

      [i now have no network connectivity with or without the mobile plugged into usb. brilliant. i have no idea how to undo all this so i'm stuck]
      [i undid it by uninstalling brctl from the still-open ubuntu software centre, then restarting]


      If anyone know why this went wrong, and how it can go right on ubuntu 12.04 LTS, please let me know.
      Cheers
      Dez

      ReplyDelete
      Replies
      1. by the way if you dont have any network connectivity how come you are posting here :)
        here is shell script that works for me on ubuntu 12.04 and android

        #!/bin/bash
        sudo ifconfig br0 down
        sudo brctl delbr br0
        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


        #in phone emulater run :

        #su
        #netcfg usb0 dhcp

        #to stop dether run :

        #sudo ifconfig br0 down
        ##sudo brctl delbr br0

        #make sure you have USB teethering on and any terminal emulator installed on your rooted phone

        Delete
    135. Or you could root your phone and do this: https://play.google.com/store/apps/details?id=jasongong.tether.usb&feature=search_result#?t=W251bGwsMSwxLDEsImphc29uZ29uZy50ZXRoZXIudXNiIl0.
      But it doesn't work for me.

      ReplyDelete
    136. So... Windows users.... Perhaps it's time for you to switch to Ubuntu Linux ;-)

      If it would work, i already did that much time ago.. (will not show the bootoptions at start up... at the moment I've no time to work with Linux, for at least 4 months...)

      Are there no news for windows users?

      ReplyDelete