简体   繁体   English

使用ifconfig在Android中打开网络,但不起作用

[英]Use ifconfig to turn on network in Android but it doesn't work

I have tried to use adb shell to operate the network interface of my phone(HTC Desire Z). 我尝试使用adb shell操作手机(HTC Desire Z)的网络接口。 You can see in the image ,I ping a site first,then turn 3G network down ,and ping it again ,it said Network is unreachable . 您可以在图像中看到,我先ping通一个站点,然后关闭3G网络,然后再次ping通,它说网络不可达。 But when I turn it on ,and use ifconfig and confirm that it is really on .But when I ping it it always said that Net work is unreachable . 但是,当我打开它,并使用ifconfig并确认它确实处于打开状态时。但是当我ping它时,它总是说网络无法访问。 Who can help me ?!!? 谁能帮我 ?!!?

This is my console content :(btw ,I am a new user and not allowed to post image) 这是我的控制台内容:(顺便说一句,我是新用户,不允许发布图像)

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]

I am the Author and I got the answer. 我是作者,得到了答案。 When turn down a interface your IP is released . 当关闭接口时,您的IP被释放。 Using "netcfg rmnet0 dhcp " to make a ip avaible first and then you can ping a site as you want . 首先使用“ netcfg rmnet0 dhcp”使一个ip可用,然后您可以根据需要ping一个站点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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