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
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:
- 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.
- 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.
So... Windows users.... Perhaps it's time for you to switch to Ubuntu Linux ;-)

Awesome!
ReplyDeleteAlso might want to mention that for XP you need to dl the usb driver manually.
http://www.android.com/tether
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.
ReplyDeleteCould someone help me out?
ReplyDeleteI 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.
On Linux you can.
ReplyDeleteOn 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.
Hi,
ReplyDeleteCan you please explain how can I bridge the usb port to the NIC in Windows? I got stuck with that :/
I'm using Windows 7. I shared my ethernet internet connection to the USB tether device.
ReplyDeleteIn 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?
OK it is working now. After setting up ICS type in console emulator on your phone:
ReplyDeleteifconfig 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.
Type-o, change the usb1 to usb0, sorry.
ReplyDeleteNice ! 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
ReplyDeletecat /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...
I worked out the DNS issue. See my second comment :)
ReplyDeleteWhat I Have found
ReplyDeleteXP
ICS wont work
Bridge Works sometimes
Windows 7
ICS works
Bridge Fails
Any pointers?
I tried this in my rooted Nexus One with Ubuntu.
ReplyDeleteThere is no response when I run the statement on the phone.
netcfg usb0 dhcp
Any help ?
I am not able to get dhcp for android working, it does not returns an address.
ReplyDeleteI have tried to do it manually, but I have got no success. Is there some way around ?
Hi,
ReplyDeleteIf 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 ;-)
I tried to same steps as mentioned till step 3.
ReplyDeleteWhen 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 )
Hi,
ReplyDeleteIn 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
The command
ReplyDeleteiptables -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
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.
ReplyDeleteI even tried changing the mac address of usb0 but still the dhcp didn't work.
Finally I got the solution.
ReplyDeleteIn 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?
Does the phone needs be rooted ?
ReplyDeleteIs this possible with 2.1 also ? .If this needs anything different ,could you list please .Thanks.
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.
ReplyDeleteHow can we solve it?
kunal I've got the same errors with iptables -F, what is the solution you found?
ReplyDeleteI 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?
ReplyDeleteAfter giving the command
ReplyDelete./adb shell netcfg usb0 dhcp
I am getting the error:
action 'dhcp' failed (Permission denied)
Anyone has any idea what am I missing....
If you enable USB tethering, you cannot execute adb shell commands from your computer.
ReplyDeleteThis article, at best, is a broken set of instructions.
...to those who got this working:
ReplyDeletewhen 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?
Any chance to port this to a bluetooth interface?
ReplyDeleteI'd really love to connect my HTC to another bluetooth-internet-sharing mobile phone.
Also willing to pay for an app doing this!
Thanks
Same as everyone else. Running "su
ReplyDeletenetcfg usb0 dhcp" does not respond on the phone.
Rosetta Stone Spanish Spain
ReplyDeleteGreat precise info, I've been searching on this topic for a while. Bookmarked and recommended!
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.
ReplyDeleteoffice activation
Works fine with Linux Mandriva ! Thanks !
ReplyDeleteAw, 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.
ReplyDeleteoffice product key
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.
ReplyDeleteHi I am having LG GT540 with Android 2.1
ReplyDeletei want to do reverse tether. I am having a PC with XP XP3 any body can tell me how to do reverse tether
When my phone (HTC Wildfire w/ Android 2.2) is in USB-Tethering-mode I cannot execute any adb-commands.
ReplyDeleteWhen 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?
thx, it work for me.
ReplyDeletei can go to marklet and see all the apps, but i cant download the app.
have some1 same issue?
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..
ReplyDeleteI also noticed that after typing ifup br0 and dhclient br0, i can't browse on my laptop (opensuse 11.2) any ideas?
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?
ReplyDeleteHello everyone!
ReplyDeletePlease 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! ;-)
Looks great!
ReplyDeleteStill 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
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.
ReplyDeleteSo you cannot ./adb shell netcfg usb0 dhcp.
I am also seeing the described problem with locking network connection on opensuse 11.3 as well as the topic regarding the adb commands.
ReplyDeleteIt would be really great, if I'd find a solution in order to be able to use my Linux-PCs internet connection via USB
You are the man! reverse tethering worked like a charm on my Moto Droid!
ReplyDeletePlease, can someone who managed to make it work specify what Linux distro are they using?
ReplyDeletenever 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!
ReplyDeleteIs there any simple way to do it without become an androïd Guru ?
ReplyDeleteI just want it to work and don't want to learn shell... Where do i click ?
The topmost right button which says close.
ReplyDeleteif i input adb shell netcfg usb0 dhcp on my pc i get the error "action 'dhcp' failed
ReplyDeleteand if i input netcfg usb0 dhcp on my phone i get "action 'dhcp' failed (permission denied)
any ideas?
That's a shame that Android doesn't support reverse tethering natively when Windows Mobile does it for many years now!
ReplyDeleteI have the same problem several people here noticed, that is some application work and some don't after creating the connection.
ReplyDeleteFor 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?
Know of a tethering application on the market that this guide works with?
ReplyDeleteI 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 :(
It worked on my rooted Motorola Defy (Android 2.1) without USB tethering app. I have Windows Vista 32bit and I used ICS.
ReplyDeleteI am getting the error- action 'dhcp' failed (Permission denied)
ReplyDeletewhen 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...
Hi there, I like the promise of this article, but before I start I want to know what I'm getting into.
ReplyDeleteWhat do I have to do to execute "On Windows computer, bridge the 2 network interfaces". What does that mean?
@March 25, 2011 4:44 AM
ReplyDeleteare 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 ?
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?????????
ReplyDeleteThanks again.........
I can't download from android market. Downloading is paused all the time. What should i do????????????
ReplyDeleteHi
ReplyDeleteI'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.
do you have now an app for reverse usb tether?
ReplyDeletei didn`t understand this how to.
i hope you have an app!!
Sry for bad english!
I finally got it to work, might be worth mentioning that the command "netcfg usb0 dhcp" took a little while to finish
ReplyDeletewhere do i get this app?
ReplyDelete"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
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.
ReplyDelete#!/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
I have an optimus one phone,
ReplyDeleteits 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...
@rQ have the same phone, same issue, to resolve, run the command in su.
ReplyDeleteIt worked for me.
This is Kiran. Any updates to make it work for Windows PC.
ReplyDeleteits working on my rooted G1 running custom 2.2.1 ROM.
ReplyDeleteAll 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
Any chance to create a script for reverse tethering and a script for back to the phone own tethering?
ReplyDeleteHi, Have you been able to make the program to automate this process? It will really help a lot of people/noobs
ReplyDeleteI 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.
ReplyDeleteHave 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.
ReplyDeleteRugga.. Awsome Work. You are a Star.
ReplyDeleteIts 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
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!
ReplyDeleteWeb hosting
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.
ReplyDeleteRegarding 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.
ReplyDeleteSomeone should write an app to do this.
Some one did ...
ReplyDeleteThierry 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.
Well I did everything but when I type "adb shell netcfg usb0 dhcp"
ReplyDeleteOr
"su
netcfg usb0 dhcp"
Nothing happens and on the PC the device is not found :(
I understood what to do but not how to. Which 2 connections do i have to bridge?
ReplyDeleteAnd 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
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 !!!!!!!
ReplyDeleteRecently 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.......
I have samsung galaxy pop ( GT-S5570),not rooted.
ReplyDelete1) 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 :-(
Can't get step 4 to work "adb shell netcfg usb0 dhcp" just freezes the terminal same as when I do su
ReplyDeletenetcfg usb0 dhcp on the phone. All other steps worked fine.
Can please also mention how to bridge networks in windows.
ReplyDeleteMohneesh
Software Developer
"how to bridge networks in windows"
ReplyDeletehttp://www.windowsnetworking.com/articles_tutorials/wxpbrdge.html
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.
ReplyDeleteFirst 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,
continuation to my previous post...
ReplyDeleteGmail can work, but use it as a email and not gmail specific app.
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?
ReplyDeleteSuPeRfLyiN, 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.
ReplyDeleteWorks for HTC Wildfire with Cyanogenmod 7.1-RC1 connected to Ubuntu 9.10 in VMware Player on Windows XP SP3 host.
ReplyDeletethanks!
After running the following command:
ReplyDeletesudo ./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
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...
ReplyDeleteWhoops ! 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...
ReplyDeletehttps://market.android.com/details?id=service.tracetool&feature=search_result
ReplyDelete"With this solution, you can surf on your mobile (using the internet connection on your PC) through the USB tunnel AND a proxy."
i am behind proxy connection windows 7 bridged
ReplyDeleteifconfig 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
https://market.android.com/details?id=service.tracetool&feature=search_result
ReplyDelete"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?
I recently realized that this feature comes default in the new 2.3 OTB HTC phones. They just call it "Internet pass-through".
ReplyDeleteNo root. No bridging required.
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".
ReplyDeleteThe 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
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?
ReplyDeleteI followed the instructions and nothing seems to happen in my terminal after su netcfg usb0 dhcp step.
ReplyDeleteIs it possible for someone to make a video of the entire process on ubuntu?
I'm on TMobile g2x. Android 2.3.4.
has anyone figured out how to download market apps
ReplyDeleteOk, 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.
ReplyDeleteYou can try Port Fowarding. I think it's very easy but work.
ReplyDeletehttp://www.codeproject.com/kb/android/usbportforwarding.aspx
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?
ReplyDeleteI have executed such things and perform well!Thanks
ReplyDeleteWant to connect Android mobile to laptop internet by USB cable
ReplyDeleteHello,
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.
Thank you Nadan, greatly appreciated!!!
ReplyDeleteJakub
Nandan - your post was fundamental, thank you very much...
ReplyDeletei hope someone comes up with an apk and a server which does everything for us
ReplyDeleteHi,
ReplyDeleteI'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.
Pity "netcfg usb0 dhcp" doesn't automatically set the dns: just as well you can do it with setprop
ReplyDeleteHi,
ReplyDeleteI'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
for me it works with win xp:
ReplyDeletejust 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
This one worked for me on windows 7. Even market works following the second post in that thread. :)
ReplyDeletehttp://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.
Dear All Experts...
ReplyDeleteon 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
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 :)
ReplyDeleteLost the link somehow.......
ReplyDeletehttp://stackoverflow.com/questions/7626564/android-usb-reverse-tethering-how-to-fool-the-apps
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?
ReplyDeletewhat about android 2.3.4 ..would work ?
ReplyDeletei 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 :(
Does it supposed to work with a non-rooted phone??
ReplyDeleteBecause 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
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"
ReplyDeleteis there anyway to activate full access to internet with this way, because no syncing, no downloading, just browsing, any ideas???
ReplyDeletedid u find away ? :)
Deleteyes
ReplyDeleteWell then tell us
ReplyDeleteAlternativelly, you can use NAT forwarding/masquerading on the GNU/Linux box (it's easier and compatible with WiFi lan):
ReplyDeleteFirst, 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
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
ReplyDeleteThere'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.
ReplyDeleteSee this video to learn how to use it: http://www.youtube.com/watch?v=iAkUSMyTpcA
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.
DeleteTethering works find for me with CyanogenMod 6.0 RC1 on a HTC Desire (myTouch) and Linux.
ReplyDeleteOn 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";
}
ReverseTehter. A+++
ReplyDeleteThanks Anonymous so much. It's fantastic. I can even use the Market to download apps.
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.
ReplyDeleteI cant get it work :
ReplyDeletecutiyar@cutiyar:~$ adb shell netcfg usb0 dhcp
action 'dhcp' failed (No such device)
cutiyar@cutiyar:~$
thanks.
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???
ReplyDeletehey i tried it in ubuntu with my ROOTED Galaxy ACe 2.3.3, but din't work...can you plss help me!!
ReplyDeletein my phone's emulator it is howing action 'dhcp' failed!
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.
DeleteThe command seemed to hang on my phone even with the right name though...
there is a free app in the market called "USB reverse tethering".
ReplyDeleteYour phone has to be rooted and with USB debugging enabled.
vmware + xp + htc sync works fine for unrooted phones
ReplyDeleteSimple reverse tethering:
ReplyDeletehttp://eduyoshida.com.br/blog/2012/07/usar-a-internet-do-pc-no-android-reverse-tethering/
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.
ReplyDeleteWARNING: ubuntu users: this may not work and may kill your standard connection like it did mine.
ReplyDeleteAlso: 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
by the way if you dont have any network connectivity how come you are posting here :)
Deletehere 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
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.
ReplyDeleteBut it doesn't work for me.
just for the solution.
ReplyDeleteSo... Windows users.... Perhaps it's time for you to switch to Ubuntu Linux ;-)
ReplyDeleteIf 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?