Genymobile / gnirehtet

Gnirehtet provides reverse tethering for Android
Apache License 2.0
6.37k stars 585 forks source link

how to use forwarded port from another machine and tell gnirehtet to use that port #116

Open varundtsfi opened 6 years ago

varundtsfi commented 6 years ago

I have forwarded a port from my another machine to working machine(where Gnirehtet is running) like 3232. This forwarded port should use by gnirehtet for internet but Its not taking this port . Even I have made required changed in java by replacing 31416 to 3232 but in tunnelserver its creating a new tunnel which probably kill the forwarded port and creating a new tunnel with the 3232 port. in Relay also I have changed that DEFAULT PORT TO 3232 and in adb reverse localabstract:gnirehtet tcp:3232

when I am checking on my another machine the what actions are taking on that forwarded port Its showing nothing. but When I am doing telnet from working machine, Its working properly.

So How can I use that forwarded port for internet and give it to my mobile. I hope you got my requirement. What changes I can do here. public TunnelServer(int port, Selector selector) throws IOException { ServerSocketChannel serverSocketChannel = ServerSocketChannel.open(); serverSocketChannel.configureBlocking(false); serverSocketChannel.socket().bind(new InetSocketAddress(Inet4Address.getLoopbackAddress(), port)); SelectionHandler socketChannelHandler = (selectionKey) -> { try { ServerSocketChannel channel = (ServerSocketChannel) selectionKey.channel(); acceptClient(selector, channel); } catch (IOException e) { Log.e(TAG, "Cannot accept client", e); } }; serverSocketChannel.register(selector, SelectionKey.OP_ACCEPT, socketChannelHandler); } @rom1v Please help me. If you have any confusion to understand my requirement, I can again explain you .

rom1v commented 6 years ago

I have forwarded a port from my another machine to working machine(where Gnirehtet is running) like 3232.

What command did you execute exactly?

The easiest way consists in creating a tunnel between the adb server (on the computer where the device is plugged) and the gnirehtet relay server.

On the computer where you run gnirehtet, kill the adb server:

adb kill-server

Then create a (forward) tunnel between port 5037 on the server and port 5037 on the client. That way, every adb command executed on the server will be send to the remote adb server (as if it were local).

varundtsfi commented 6 years ago

./gnirehtet run -d 172.16.50.3 above command I am using but now independently Like If I am running relay server only also not working.

The easiest way consists in creating a tunnel between the adb server (on the computer where the device is plugged) and the gnirehtet relay server. how to achieve this means by using ssh tunnel or any other way.

I am using Ubuntu 16 Machine.
My working machine where device is connected and gnirehtet relay server is running . My another machine from where I am forwarding a port to my Working machine.

varundtsfi commented 6 years ago

Any suggestion @rom1v .

I have tried few more things but its not working.

rom1v commented 6 years ago

how to achieve this means by using ssh tunnel

From the computer where the gnirehtet relay server is running:

adb kill-server
ssh computer -CNL5037:localhost:5037

(where computer is the address of the computer where the device is plugged)