ping ping -c The ping command sends a special kind of packetan ICMP ECHO_REQUEST messageto the specified address. If a machine at that address is listening for ICMP messages, it responds with an ICMP ECHO_REPLY packet. (It's true that firewalls can block ICMP messages, rendering ping useless, but most of the time it's not a problem.) A successful ping means that network connectivity is occurring between the two machines. $ ping www.google.com ping www.google.com PING www.l.google.com (72.14.203.99) 56(84) bytes of data. 64 bytes from 72.14.203.99: icmp_seq=1 ttl=245 time=17.1 ms 64 bytes from 72.14.203.99: icmp_seq=2 ttl=245 time=18.1 ms [Results truncated for length]--- www.l.google.com ping statistics --- 6 packets transmitted, 5 received, 16% packet loss, time 5051ms rtt min/avg/max/mdev = 16.939/17.560/18.136/0.460 ms The ping command won't stop until you press Ctrl+C. This can cause problems if you forget that you're using ping because it will continue forever until it is stopped or your machine's network connection stops. I once forgot and left a ping session running for 18 days, sending nearly 1.4 million pings to one of my servers. Oops! If you want to give ping a limit, you can set the number of packets that ping is to send with the -c option, followed by a number. After ping sends out that number of packets, it stops, reporting its results. $ ping -c 3 www.granneman.com PING granneman.com (216.23.180.5) 56(84) bytes of data. 64 bytes from 216.23.180.5: icmp_seq=1 ttl=44 time=65.4 ms 64 bytes from 216.23.180.5: icmp_seq=2 ttl=44 time=64.5 ms 64 bytes from 216.23.180.5: icmp_seq=3 ttl=44 time=65.7 ms --- granneman.com ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 4006ms rtt min/avg/max/mdev = 64.515/65.248/65.700/0.510 ms The ping command is a standard and speedy way to determine basic network connectivity; even better, if you include the -c option, you'll never forget and leave ping running accidentally for 18 days. For more about using ping to diagnose network connectivity issues, see "Troubleshooting Network Problems." |