Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can i use ping command in the android emulator

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:

enter image description here

But,when i use the adb shell to connect to this emulator and try to ping www.baidu.com,it loop there,like:

enter image description here

Any idea?thx

like image 871
kaiwii ho Avatar asked Jan 09 '13 12:01

kaiwii ho


People also ask

How to use ping utility on Android emulator?

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.

How to Ping An IP address or hostname using Android?

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’

How to Ping a host in QEMU emulator?

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).

Where does the ‘ping’ command come from on Android mobiles?

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.


1 Answers

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

like image 74
Mehmet Mersin Avatar answered Sep 30 '22 04:09

Mehmet Mersin