【问题标题】:Use ifconfig to turn on network in Android but it doesn't work在Android中使用ifconfig打开网络但它不起作用
【发布时间】:2012-07-04 19:31:37
【问题描述】:

我尝试使用 adb shell 来操作我手机的网络接口(HTC Desire Z)。 如图所示,我先ping了一个站点,然后把3G网络关掉,再ping,它说网络不可达。 但是当我打开它并使用 ifconfig 并确认它确实打开时。但是当我 ping 它时,它总是说网络无法访问。 谁能帮帮我?!!?

这是我的控制台内容:(顺便说一句,我是新用户,不允许发布图像)

ping 211.69.198.222
PING 211.69.198.222 (211.69.198.222) 56(84) bytes of data.
64 bytes from 211.69.198.222: icmp_seq=1 ttl=46 time=356 ms
64 bytes from 211.69.198.222: icmp_seq=2 ttl=46 time=294 ms
64 bytes from 211.69.198.222: icmp_seq=5 ttl=46 time=342 ms
64 bytes from 211.69.198.222: icmp_seq=6 ttl=46 time=341 ms
64 bytes from 211.69.198.222: icmp_seq=8 ttl=46 time=342 ms
64 bytes from 211.69.198.222: icmp_seq=9 ttl=46 time=330 ms
^C
--- 211.69.198.222 ping statistics ---
9 packets transmitted, 6 received, 33% packet loss, time 8025ms
rtt min/avg/max/mdev = 294.831/334.533/356.018/19.263 ms
# ifconfig rmnet0
rmnet0: ip 172.22.39.243 mask 255.255.255.248 flags [up broadcast running multicast]
# ifconfig rmnet0 down
# ping 211.69.198.222
connect: Network is unreachable
# ifconfig rmnet0 up
# ping 211.69.198.222
connect: Network is unreachable
# ping 211.69.198.222
connect: Network is unreachable
# ifconfig rmnet0
rmnet0: ip 172.22.39.243 mask 255.255.255.248 flags [up broadcast running multicast]

【问题讨论】:

  • 你说的大部分我都听不懂。但我认为您可能需要添加到默认网关的路由。
  • 同样的问题,但我没有 netcfg 命令。我已经尝试过 dhcptool rmnet0,它给了它 ip 但仍然没有工作:(

标签: android linux networking adb ifconfig


【解决方案1】:

我是作者,我得到了答案。 当关闭接口时,您的 IP 将被释放。 使用“netcfg rmnet0 dhcp”先使一个 ip 可用,然后你可以根据需要 ping 一个站点。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-09-11
    • 2021-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-18
    • 1970-01-01
    相关资源
    最近更新 更多