I encounter a very strange problem: In my host pc,i use dhcp. And my emulator,4.0.3 can log into the net via browswer.like:
But,when i use the adb shell to connect to this emulator and try to ping www.baidu.com,it loop there,like:
Any idea?thx
For those of you who know, ping utility does not work on Android Emulator. This is because emulator has no ICMP support on QEMU with user mode networking. QEMU user networking mode details can be found here. The solution to get ping working on emulator is by adding another virtual network interface on the emulator.
The steps to ping an IP address or hostname using Android. Step 1: Open the Google Play Store and search for Terminal Emulator on it. Download it. Step 2: Now type the following command without the quotes and hit the enter key. ping -c ‘number’ ‘domain_name.ext’
It seems like Qemu user networking mode (default for android emulator) does not support ICMP protocol (ping). So you cannot ping a host in android emulator without changing network settings. If you just want to see if you can access a certain host, you can try to connect to a port you know it's open using netcat (nc).
However, we also hear it in the environment of our Android mobiles. Many users claim that the ‘ping’ command has its origin in the sonars of submarines that send acoustic signals to detect obstacles or map the seabed.
It seems like Qemu user networking mode (default for android emulator) does not support ICMP protocol (ping). So you cannot ping a host in android emulator without changing network settings.
http://wiki.qemu.org/Documentation/Networking#User_Networking_.28SLIRP.29
If you just want to see if you can access a certain host, you can try to connect to a port you know it's open using netcat (nc). For example to check if you can access www.baidu.com, you can try connecting port 80 (HTTP)
nc -v www.baidu.com 80
You will see a message like this if connection is successful
Connection to www.baidu.com 80 port [tcp/www] succeeded!
If you really want to be able to use ping, you can follow the steps in this blog post. Sorry, instructions are for linux only. But it may give you an idea on how to do it in windows.
http://emulatorforandroid.blogspot.jp/2013/04/enabling-ping-and-icmp-on-android.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With