Genymobile / gnirehtet

Gnirehtet provides reverse tethering for Android
Apache License 2.0
6.13k stars 565 forks source link

how to access localhost from android mobile after connecting using gnirehtet #71

Closed sant527 closed 6 years ago

sant527 commented 6 years ago

I am using this to do reverse tethering. I installed the apk on my android and after connecting my android phone by USB i ran ./gnirehtet run. And now i am able to acces internet on my android.

But i have a server running on the localhost on my laptop. I can access it using 127.0.0.1:8000 from browser on laptop. How to access it on my android mobile. Which ip i have to use

rom1v commented 6 years ago

The mapping is hardcoded: 10.0.2.2.

sant527 commented 6 years ago

its very flickering. sometimes it shows no progress

rom1v commented 6 years ago

Could you give more details?

sant527 commented 6 years ago

I think there is some problem with the port:

I try 10.0.2.2 it opens my localhost

but if I localhost running on 8000 port then 10.0.2.2:8000 is not loading.

It shows blank when i open in chrome

rom1v commented 6 years ago

i am using django server

./manage.py runserver 10.0.0.2:8000

Your server must listen on localhost (127.0.0.1), and your client must access it through 10.0.2.2.

sant527 commented 6 years ago

2018-01-01 17:09:29.761 INFO TcpConnection: 10.0.0.2:43916 -> 10.0.2.2:8000 Close 2018-01-01 17:09:29.761 INFO TcpConnection: 10.0.0.2:43917 -> 10.0.2.2:8000 Close 2018-01-01 17:09:29.761 INFO TcpConnection: 10.0.0.2:43918 -> 10.0.2.2:8000 Close 2018-01-01 17:09:29.848 INFO TcpConnection: 10.0.0.2:43919 -> 10.0.2.2:8000 Close

rom1v commented 6 years ago

I think there is some problem with the port

I can't reproduce.

I started a simple http server on the computer listening on 127.0.0.1:8000:

python3 -m http.server --bind 127.0.0.1 8000

And I access http://10.0.2.2:8000/ from the device, it works as expected.

sant527 commented 6 years ago

thats true. I think django is having some problem. I running a localserver on Django. Also i have localhost running on my apache server, that also hangs.

The below is the result of opening 127.0.0.1:8000 on my laptop browser

$ ./manage.py runserver 127.0.0.1:8000 Performing system checks...

System check identified no issues (0 silenced). January 05, 2018 - 10:07:11 Django version 2.0, using settings 'webarticles.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C. [05/Jan/2018 10:07:17] "GET / HTTP/1.1" 200 4067 [05/Jan/2018 10:07:17] "GET /static/bgt/news-card.css HTTP/1.1" 200 10181 [05/Jan/2018 10:07:17] "GET /static/js/lib/jquery-min.js HTTP/1.1" 200 96381 [05/Jan/2018 10:07:19] "GET /media/Article/None/IMeMine.jpg HTTP/1.1" 200 162844 [05/Jan/2018 10:07:19] "GET /static/inshorts/logo-old.png HTTP/1.1" 200 13439 [05/Jan/2018 10:07:19] "GET /static/inshorts/ajax-loader.gif HTTP/1.1" 200 723

whereas the following is when i open in my android browser:

$ ./manage.py runserver 127.0.0.1:8000 Performing system checks...

System check identified no issues (0 silenced). January 05, 2018 - 10:08:49 Django version 2.0, using settings 'webarticles.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C. [05/Jan/2018 10:08:52] "GET /static/bgt/news-card.css HTTP/1.1" 200 10181 [05/Jan/2018 10:08:53] "GET /media/Article/None/IMeMine.jpg HTTP/1.1" 200 162844 [05/Jan/2018 10:08:53] "GET /static/inshorts/ajax-loader.gif HTTP/1.1" 200 723

So many things are not loading. it gets stuck.

rom1v commented 6 years ago

OK, so for now I'm closing the issue, if you have new information, feel free to reopen.