Search code examples
network-programmingadb

adb reverse to distant machine on same network


I'm struggling to set-up my dev environnement and would appreciate some help.

I have a switch which gives internet to Computer:A (my servers, ip x.x.x.1) and Computer:B (Working station, ip x.x.x.2, thus same network). Neither of these computers have Bluetooth nor Wifi, everything goes through ethernet.

I have a Android device (Tablet:C) I plug to Computer:A. Using adb reverse tcp:80 tcp:80 and other ports I'm able to access my Apache and other servers configured on A. In the app I'm developping, it's written in the config file I'm using localhost:xx for my servers. Everything works, since abd reverse tells that connections to localhost:xx on C will be redirected to localhost:xx on A.

But I would like to connect my Tablet:C to my Computer:B. So I would be able to debug, to push my apk faster, etc.

Is there a way I can plug C to B via USB, and make a sort of adb reverse tcp:xx tcp:xx not to connect to localhost of B but to reach A?

Thanks


Solution

    1. Nothing specific to do on ComputerA but enable SSH

    2. Use SSH tunneling between A and B to forward interesting ports, e.g 80. On computer B : ssh ip_A -L 8080:localhost:80 to specify that connections to the 8080 localhost port are to be forwarded to the port 80 on the remote side.

    3. Plug the android device on ComputerB adb reverse tcp:80 tcp:8080 to specify that connections to localhost:80 (Android device) will be routed to localhost:8080 (working station), which will be routed to ComputerA:80 (servers), thanks to SSH tunneling