Click here to Skip to main content
15,868,141 members
Articles / Mobile Apps / Android

Android Usb Port Forwarding

Rate me:
Please Sign up or sign in to vote.
4.88/5 (52 votes)
26 Dec 2011CPOL4 min read 1.7M   201.8K   155   315
This tool creates an USB tunnel between the android and the PC. The tunnel will forward communications to and from the host.

Download Windows part : AndroidTool.zip - 3.2 MB
Download Android part Tracetool_service.zip - 99.04 KB

(See article in Portuguese here)

Important Update :

For rooted phone, you can use my other program (not yet on codeproject) :

Android reverse tethering : http://forum.xda-developers.com/showthread.php?t=1371345 

Introduction   

The Android architecture does not allow to start communication from the Android to the host through the USB cable.The opposite is possible, using the Google "Android Debug Bridge" (ADB in short).    

This tool will act as a tunnel between the Android client application and the host server. It is a software implementation of a router doing IP port forwarding.

global.png

On the Host part, you have to declare the ports you want to be opened on the Android and the tunnel will transfer communications between the android and the host. The host can be any server on the network or your local host. 

Prerequisits   

  • Enable "Usb debuging" on your Android : Go to parameters / Applications / Development and check  "Usb debuging" 
  • Install "Usb Tunnel" on your Android (see donwnload link on top of the article) or from the market :
     
  • Screenshot - market.jpg

  • Install the host windows application (see download link on top of the article) or this skydrive link or this GDoc link   
  • On the configuration panel, enter the path to the ADB program. ADB is part of the Android SDK. The installation includes the minimum files required.
  • Add tunnels. Each tunnel is composed of a name, an Android port (low port like 80 can't be used), a host IP and a host port (can be different from the android port)  
 config.png

HTTP proxy 

If Tethering is a technology that allows you to use the mobile internet connection on your PC, this tool gives you the opposite. It's a sort of Reverse Tethering.   

You can now surf on your mobile (using the internet connection on your PC) through the Usb tunnel and via a proxy. 

If you are on a company network, ask your administrator what IP adddress and port he is using for the proxy. In some cases it can be the default gateway (run ipconfig command at the DOS prompt to find out what the default gateway is). 

If you are on a private network and you have no clue about the proxy adress and port, you can use a public proxy (do search for "Public proxy" on the internet). To help you out, here is link to a list of proxies. 

Another possibility is to install a local http proxy server like squid.  

Step 1 : configure the windows part. Since low ports can't be used, you should use a different high port for the android and another port for the host.  

Sample configuration for a company network : (192.168.xxx.xxx) on port 80 

 httpProxy.png     

Sample configuration for a public internet proxy on port 8080 

httpProxy2.png

Step 2 : Connect he USB cable (of course).  Click the refresh button to display your device in the device list then click connect. The Android Usb tunnel service will start in the background. A connection icon will be added on the notification pannel.  

Step 3 : Setup your browser to use a proxy. Depending on the version of your Android OS, it's possible to define a http proxy in the advanced wifi settings menu (Not tested, available in some Android, but not all). 

Normal Chrome browser

  • I didn't find a way to get it working. Forget about TransparentProxy, ProxyDroid or AsProxy. that require Root and don't work  

Opera mobile 

  • Enter opera:config in the address bar 
  • Expand the proxy line  
  • HTTP server : 127.0.0.1:8080  
  • HTTPS server : 127.0.0.1:8080  
  • Use HTTP : checked 
  • Use HTTPS : checked 
  • Click "Save" 

Firefox Mobile

  • Enter about:config in the address bar 
  • In the search filter (below address bar), enter "proxy"
  • Set network.proxy.http to 127.0.0.1 
  • Set network.proxy.http_port to 8080  
  • Set network.proxy.type to 1 (Manual). Default is 5 (system)  

Skyfire

  •  I didn't find a way to get it working. 

Step 4 : Enjoy! enter any URL on your browser. Your firewall may detect that AndroidTool.exe is trying to access the internet. Give him the rights to access the proxy. 

running.png 

In this screenshot, you can see the number of active connections , closed connections, total bytes transfered (to and from) 

I checked with an internet speed test. It's just a little bit slower. 

History 

May 2011 : 

   First version  

Decembre 2011 : For rooted phone, you can use my other program (not yet on codeproject) :

   Android reverse tethering : http://forum.xda-developers.com/showthread.php?t=1371345 


 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
Belgium Belgium
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
AnswerRe: Doesnt pick up my device Pin
Member 86015262-Jul-12 8:49
Member 86015262-Jul-12 8:49 
QuestionModify this code? Pin
Member 90727424-Jun-12 15:22
Member 90727424-Jun-12 15:22 
AnswerRe: Modify this code? Pin
Thierry Parent4-Jun-12 20:39
Thierry Parent4-Jun-12 20:39 
Generalre: this tool Pin
piyush61925-May-12 0:39
piyush61925-May-12 0:39 
Questionaaaaaaaa Pin
siger1318-May-12 2:47
siger1318-May-12 2:47 
GeneralMy vote of 5 Pin
klaydze11-May-12 3:22
klaydze11-May-12 3:22 
Questionconnect android to Visual Basic Pin
rais_rg26-Apr-12 17:15
rais_rg26-Apr-12 17:15 
QuestionHow do i find out my android port and host server port? Pin
Member 882888516-Apr-12 19:47
Member 882888516-Apr-12 19:47 
AnswerRe: How do i find out my android port and host server port? Pin
Thierry Parent16-Apr-12 20:45
Thierry Parent16-Apr-12 20:45 
QuestionReverse tethering for non rooted android. Pin
archyys7716-Apr-12 4:09
archyys7716-Apr-12 4:09 
AnswerRe: Reverse tethering for non rooted android. Pin
Thierry Parent16-Apr-12 20:38
Thierry Parent16-Apr-12 20:38 
Questionreverse tethering Pin
Vinodr12819938-Apr-12 0:27
Vinodr12819938-Apr-12 0:27 
Questionthanks Pin
dj loon5-Apr-12 22:58
dj loon5-Apr-12 22:58 
AnswerRe: thanks Pin
Thierry Parent6-Apr-12 13:31
Thierry Parent6-Apr-12 13:31 
Questioni cant make any sense of this Pin
bobbycracky19-Mar-12 16:28
bobbycracky19-Mar-12 16:28 
QuestionNot detecting handset Pin
xperia ST1817-Mar-12 1:42
xperia ST1817-Mar-12 1:42 
AnswerRe: Not detecting handset Pin
arthuragb17-Mar-12 7:50
arthuragb17-Mar-12 7:50 
GeneralRe: Not detecting handset Pin
Member 86015262-Jul-12 8:50
Member 86015262-Jul-12 8:50 
Questionerror: more than one device and emulator Pin
arthuragb15-Mar-12 7:01
arthuragb15-Mar-12 7:01 
QuestionUpload a working version? Pin
Anthraxbaby9-Mar-12 8:47
Anthraxbaby9-Mar-12 8:47 
Answerexplanation Pin
yemba26898-Mar-12 15:41
yemba26898-Mar-12 15:41 
GeneralRe: explanation Pin
yemba26898-Mar-12 16:32
yemba26898-Mar-12 16:32 
GeneralRe: explanation Pin
Thierry Parent8-Mar-12 20:45
Thierry Parent8-Mar-12 20:45 
GeneralRe: explanation Pin
arthuragb17-Mar-12 7:14
arthuragb17-Mar-12 7:14 
Questiondisconnecting after 2-3 minutes !! Pin
indtram8-Mar-12 1:32
indtram8-Mar-12 1:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.