【问题标题】:Android device can't ping PC through adb shellAndroid 设备无法通过 adb shell ping PC
【发布时间】:2025-10-07 21:10:02
【问题描述】:

我的 Android 手机已连接到我的 PC(安装了 Android SDK 的 Windows 10)。我将我的 PC 设置为具有移动热点,以便手机可以连接到 PC 网络。我的 PC 可以 ping 电话的 IP 地址,但是当我想从电话的外壳(通过adb shell) ping PC 时,它就是无法 ping 它。我在 PC 上有一个 HTTP 服务器,需要手机访问服务器,目前无法访问。

PC IP 地址为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 . . . . . . . . . :

而手机的IP地址是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

我也试过不带移动热点的时候都连接到同一个路由器,但又是同样的问题。

有什么问题?Windows 是否有一些设置需要更改以提高可见性和可访问性?

【问题讨论】:

  • 检查您电脑的防火墙设置。
  • 我知道要检查什么。
  • 我敢打赌谷歌知道。

标签: android networking adb client-server ping


【解决方案1】:

您已经通过adb 连接(正如您提到的adb shell),然后只需进行反向端口映射(根据您的情况更改端口

adb reverse tcp:8080 tcp:8080

然后,当您的设备访问localhost:8080 时,它将被重定向到yourpc:8080

【讨论】: