System Administration Guide: IP Services

ping Command

Use the ping command to find out whether an IP connection exists for a particular host. The basic syntax is:

/usr/sbin/ping host [timeout]

In this syntax, host is the host name of the machine in question. The optional timeout argument indicates the time in seconds for ping to continue trying to reach the machine—20 seconds by default. The ping(1M) man page describes additional syntaxes and options.

When you run ping, the ICMP protocol sends a datagram to the host you specify, asking for a response. ICMP is the protocol responsible for error handling on a TCP/IP network. See ICMP Protocol for details.

ping Command Task Map

Table 4–6 ping Command Task Map



For Instructions, Go To ... 

Determine if a host is running 

Involves pinging the hostname 

Network Databases and nsswitch.conf File

Determine if a host is losing packets 

Involves using the -s option of the ping command

How Name Services Affect Network Databases

How to Determine if a Host Is Running

    On the command line, type the following command.

    % ping hostname

    If host hostname is up, this message is displayed:

    hostname is alive

    This message indicates that hostname responded to the ICMP request. However, if hostname is down or cannot receive the ICMP packets, you receive the following response from ping:

    no answer from hostname

How to Determine if a Host Is Losing Packets

If you suspect that a machine might be losing packets even though the machine is running, you can use the s option of ping to try to detect the problem.

    On the command line, type the following command.

    % ping -s hostname

ping continually sends packets to hostname until you send an interrupt character or a timeout occurs. The responses on your screen resemble the following:

PING elvis: 56 data bytes
64 bytes from icmp_seq=0. time=80. ms
64 bytes from icmp_seq=1. time=0. ms
64 bytes from icmp_seq=2. time=0. ms
64 bytes from icmp_seq=3. time=0. ms
----elvis PING Statistics----
4 packets transmitted, 4 packets received, 0% packet loss
round-trip (ms) min/avg/max = 0/20/80   

The packet-loss statistic indicates whether the host has dropped packets.

If ping fails, check the status of the network that is reported by ifconfig and netstat, as described in ifconfig Command and netstat Command.