Did you come here from a search engine? Click here for my main page.
ping is perhaps the most basic utility for IP networks. It simply tells you whether you can reach a given remote host (specified by name or by IP address) from where you are on the network. It can also provide information on the performance and reliability of the connection to that host.
We usually use ping to determine whether a particular host machine is "alive" (i.e., that it is turned on and answering at the given address). ping does not tell you what the remote machine does (e.g., whether it has a web server, whether anyone is logged on), what kind of machine it is (e.g., a home user, a server, etc.), or who it belongs to (the Pentagon, the Roman Catholic Church, your next-door neighbor, etc.), just whether it is online and whether a path exists to allow it to exchange IP packets with you. For spam-tracing purposes, you will probably use ping most often in conjunction with other tools like whois or traceroute.
ping uses a specialized IP protocol called ICMP (internet control message protocol), an acronym you may often see in conjunction with ping (as well as with traceroute, which also uses ICMP). In operation, ping sends out a numbered series of ICMP packets to the remote host; this host is supposed to respond to each of them, and when your computer gets the responses it prints the time required for the response.
Most modern computer operating systems (at least those with IP protocol "stacks") should have the ping command available. This includes pretty much all versions of Windows (at least from Win95 onward), and all Unix-like operating systems (including Mac OS X / Darwin). If you're still using Mac OS 9 or earlier, you do not have a command-line interface; you may, however, find a version of ping in a network tool of some sort lurking under your Apple menu.
If you don't have ping, or if you prefer a web-based interface, you search for an online version (perhaps by Googling “ping online”). Bear in mind that pinging from some other host tells you whether the host can be reached from that host, and not from your own computer. If the ping works, however, it proves that the host is indeed online.
To use ping, simply open a terminal window (or a command prompt window in Windows) and type the command thusly:
You can supply ping with either a host name (or alias) or an IP address. If you use a name, then ping will first attempt to resolve the host name to an IP address; if it cannot resolve the name, it will exit with an error message.
Here's a ping I ran to www.yahoo.com from my Mac's terminal window (the first line is the command prompt followed by my command, and the rest is the output from the command):
[localhost:~] rconner% ping www.yahoo.com
PING www.yahoo.akadns.net (188.8.131.52): 56 data bytes
64 bytes from 184.108.40.206: icmp_seq=0 ttl=51 time=24.126 ms
64 bytes from 220.127.116.11: icmp_seq=1 ttl=51 time=25.078 ms
64 bytes from 18.104.22.168: icmp_seq=2 ttl=51 time=23.183 ms
64 bytes from 22.214.171.124: icmp_seq=3 ttl=51 time=24.562 ms
--- www.yahoo.akadns.net ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 23.183/24.237/25.078 ms
I stopped this ping after four packets by typing control-C; when you ping on the public network, it is considered poor form to send any more packets than you require in order to verify the connection. Also, don't use the "-f" (flood) option with ping, as it will send packets as fast as it can and places a burden on the remote computer (plus, if you get obnoxious with flood-pings, you can find yourself in trouble for launching a "denial of service" attack). Again, you don't need to see any more than a dozen or so returns to know that you can make a good connection.
Note that this ping also printed the IP address (126.96.36.199) it found for www.yahoo.com; it got this using a DNS lookup. You can use this address for further work, saving yourself the trouble of an extra nslookup or host command.
As we see, the times for the pings are pretty short; more importantly, however, they're consistent (about the same for each packet), indicating that you have a good, stable network connection. This is also borne out by the fact that each packet received a reply (i.e., there are no missing icmp_seq numbers in the response, and the summary shows zero packet loss).
A ping can fail for any of a number of reasons, but they usually boil down to one of these:
Here's an example of a ping failure due to an unresolvable host name:
[G4733:~] rconner% ping jethro.rickconner.net
ping: unknown host jethro.rickconner.net
Here's an attempt to ping an address that isn't reachable from where you sit (possibly because it is unrouteable or because you aren't connected to the network):
[G4733:~] rconner$ ping 192.168.0.3
PING 192.168.0.3 (192.168.0.3): 56 data bytes
ping: sendto: No route to host
And here's what might happen if you try to ping a host that is offline or that doesn't want to ping with you:
[G4733:~] rconner% ping 188.8.131.52
PING 184.108.40.206 (220.127.116.11): 56 data bytes
--- 18.104.22.168 ping statistics ---
68 packets transmitted, 0 packets received, 100% packet loss
Here, ping sent 68 packets (over more than a minute of activity) but got no response and printed nothingit seems to "hang" (although it is still working) and you have to type control-C to stop it. There's no easy way to tell exactly why you didn't get an answer in such cases, but if you're on the public network (where routing is ususally pretty reliable) the chances are good that there's no host at this address, or that the host is offline. It's also possible (if rare) that the host has been configured not to reply to pings.
Legend: new window outside link tools page glossary link
|(c) 2003-2008, Richard C. Conner (
06305 hits since March 28 2009
|Updated: Wed, 11 Jun 2008|