简体   繁体   中英

Android device can't ping PC through adb shell

I have my Android phone connected to my PC (Windows 10 with Android SDK installed). I set up my PC to have a mobile hotspot so the phone can be connected to the PC network. My PC can ping the phone's IP address, but when I want to ping the PC from the phone's shell (through adb shell ), it just can't ping it. I have a HTTP server on the PC and need the phone to reach to the server, which is not reachable right now.

The PC IP address is 192.168.137.1 :

Wireless LAN adapter Local Area Connection* 2:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::345d:2505:82fa:3cd5%9
   IPv4 Address. . . . . . . . . . . : 192.168.137.1
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :

And the phone's IP address is 192.168.137.159 :

wlan0     Link encap:UNSPEC
          inet addr:192.168.137.159  Bcast:192.168.137.255  Mask:255.255.255.0
          inet6 addr: fe80::5ca7:98ff:feea:cb17/64 Scope: Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:16441523 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8750144 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:17116348103 TX bytes:4458547550

I also tried it without mobile hotspot when both connect to the same router, but same issue again.

What is the problem? Does Windows have some settings that need to be changed for visibility and reachability?

You are already connected via adb (as you mentioned adb shell ), then just do a reverse port mapping ( changes ports according to your case )

adb reverse tcp:8080 tcp:8080

then, when your device access localhost:8080 it will be redirected to yourpc:8080 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM