Network Monitoring  «Prev  Next»

Lesson 2The ping command
ObjectiveUse the ping command to check network status.

Check network status using the ping Command

Undoubtedly the single most useful command for checking network status is ping. The ping command uses the Internet Control Message Protocol (ICMP)[1]. This protocol, which operates at the network layer of the TCP/IP[2] protocol stack, is used to pass error information among machines on the Internet.
In its simplest form, ping generates a series of ICMP echo-request packets directed at a particular machine. Upon receipt of such a packet, the target machine is required to generate an ICMP echo-reply packet directed at the sender. If these packets can be successfully exchanged, a network connection between the two machines exists.
View the Slide Show below to see how ping can be used to test network connectivity.
1) Ping Command 1 2) Ping Command 2 3) Ping Command 3

Using ping when Network is broken

You will often use ping when your network is broken. In particular, name service may not be available. In this case, you should use IP addresses instead of host names, and you should use the appropriate option to ping (usually -n) to tell the ping not to try to look up host names, but rather to report only numbers.

Useful options for the ping command

The table below lists useful options for the Linux version of the ping command.

Linux Version of ping Command

Option Purpose
-n Do not try to look up IP names; just use numbers. Use this option if name service is broken.
-c count Stop after sending count packets.
-i interval Wait interval seconds between packets.
-r Ignore the routing table; assume the host is on the local network. Useful if default route is messed up, or with other routing problems.
-s size Send a packet of given size (default is 64 bytes total).

Solaris Version of ping Command

The Solaris version of ping is set up a little differently. The Solaris equivalent of Linux ping is
ping -s hostname
, which enables you to receive a report on each packet sent to the specified machine. (If you do not include the -s option with Solaris ping, the report you receive will simply state whether the machine you ping is alive or not.) Other useful Solaris ping options include:

Option Purpose
-n Do not try to look up IP names; just use numbers. Use this option if name service is broken.
-r Ignore the routing table; assume the host is on the local network. Useful if default route is messed up, or with other routing problems.
-s size Send a packet of given size.
-c number Send specified number of packets.

[1] (ICMP)Internet control message protocol:ICMP is a protocol used to communicate errors or other conditions at the IP layer
[2]TCP/IP: TCP/IP is the network protocol suite used by the Internet and most local area networks.