PING(8) PING(8)
990412
NAME
ping - send ICMP ECHO request packets to network hosts
SYNOPSIS
ping [options] host [length [count]]
Flags: [-c | -f] [-F] [-Q] [-LR] [-a] [-mnqv] [-dr]
Options: [-l length] [-k count] [-p preload] [-D pattern] [-T tos]
Options: [-b netbits] [-g gateway] [-t timeout] [-s source_addr]
DESCRIPTION
The Internet is a large and complex aggregation of network hardware,
connected together by gateways. Tracking a single-point hardware or
software failure can often be difficult. ping utilizes the ICMP
protocol's mandatory ECHO request datagram to elicit an ICMP ECHOREPLY
from a host or gateway. ECHO request datagrams (``pings'') have an IP
and ICMP header, followed by a struct timeval, and then an arbitrary
number of ``pad'' bytes used to fill out the packet.
Default datagram length is 64 bytes (8 ICMP header bytes + 56 data
bytes), but this may be changed using the command line option length.
The number of ping packets is unlimited, unless an explicit count is
specified.
The default mode is to send a packet every timeout seconds and display
the response, including sequence number and round-trip time if the
packet size allows.
Two other modes are available (which are mutually exclusive):
SPECIAL MODES
-c Use cisco style packet sending; that is, spew packets as fast as
possible, but don't send packet N+1 until a reply or bounce or
timeout has been registered for packet N. A '!' is printed for
every valid response received and a '.' is printed when no packet
is received during the timeout period. A duplicate response
causes a '*' to be printed. When a ping request is bounced in
transit, a '#' will be printed.
-f Use floodping style packet sending; send packets as fast as
possible, attempting to send at at least 100 packets per second.
A '.' is printed for every packet sent and a backspaced '!' for
every valid response (a backspaced '#' when a ping request is
bounced in transit). The number of visible dots indicates how
much ping is ``behind''. A '*' is printed whenever a duplicate
packet is received. While waiting for outstanding packets during
termination a '!' is printed per valid response and a '#' per
bounced request.
- 1 - Formatted: November 11, 2025
PING(8) PING(8)
990412
FLAGS
-F Fast ping. In normal mode, send a packet as soon as a response
is received without delaying for the regular timeout period. This
is similar to cisco style except for the printing of the response
messages.
-Q Quick ping. This suppresses all normal output as well as the
final statistics summary. The program quits with an ``alive''
indication as soon as a valid response is received. It quits with
an ``unreachable'' indication as soon as a bounce message is
received.
-L Insert "loose source route" IP option in outgoing packets.
Without explicit gateways given by the -g option, this selects a
route to the destination host and back to the source host. This
option only works on systems that allow setting of IP options.
-R Insert "record route" IP option in outgoing packets, summarizing
the routes the packets have traveled when the program quits. In
"very verbose" mode, the route is displayed for each reply
received. This option only works on systems that allow setting
of IP options.
-a All-address mode. If the destination host has multiple
addresses, ping will probe all addresses if this option is set.
Normally only the first address as returned by the DNS resolver
is attempted.
-m Missed mode. Enable printing of a summary of missed valid
responses at the end.
-n Numeric mode. Disable reverse hostname lookup of all IP
addresses. By default both hostname and IP address of the
destination host are displayed in the header, summary, and
"record route" surveys, as well as in the response messages (the
latter is safe since all lookups are now cached to avoid
excessive nameserver queries). If the reverse hostname lookup
fails, just the IP address is displayed.
-q Quiet mode. Disable printing of ping response messages and
special mode markers, only display the summary when quitting.
This option is implied in quick (-Q) mode.
-v Verbose mode. All received ICMP packets, including other than
our own ECHOREPLY packets, are listed and a summary printout of
their contents is made. When specified as -vv (very verbose),
loose source route and record route information (if present) is
displayed for each response received.
-d Enable socket level debugging with the SO_DEBUG option.
- 2 - Formatted: November 11, 2025
PING(8) PING(8)
990412
-r Enable socket level processing with the SO_DONTROUTE option.
Bypass the normal routing tables and send directly to a host on
an attached network. If the host is not on a directly-attached
network, an error is returned. This option can be used to ping a
local host through an interface that has no route through it
(e.g., after the interface was dropped by routed(8C)).
-V Just print the program version number, then exit.
OPTIONS
-t timeout
In normal mode, this is the interval in seconds for sending ping
messages. In cisco or fast mode, this is the timeout ping will
wait for a reply before sending the next packet. In these modes a
new ping is sent as soon as a valid reply is received. In flood
mode this timeout does not apply. The default value is 1 second.
-s source_addr
Use the following IP address (which must be given as an IP
number, not a hostname) as the source address in outgoing probe
packets. On hosts with more than one IP address, this option can
be used to force the source address to be something other than
the IP address of the interface the probe packet is sent on. If
the IP address is not one of this machine's interface addresses,
an error is returned and nothing is sent.
-g gateway
Construct a "loose source route" via this gateway to the target
host. Up to 8 of such intermediate hosts can be specified. This
option only works on systems that allow setting of IP options.
-l length
Alternative option to specify the size of the ping packets.
-k count
Alternative option to limit the number of ping packets to be
sent.
-p preload
Specifies the number of packets to preload. They are sent at
startup before listening for a response. The default is to not
send any preload packets.
-b netbits
Specify the number of bits in the netmask that applies to given
addresses. This overrules the traditional class masks when
checking whether a given address is a broadcast address.
-D pattern
Specifies the pattern to fill unused data in the packets. The
default is to fill with the data position modulo 256. A pattern
- 3 - Formatted: November 11, 2025
PING(8) PING(8)
990412
is a string of hex digit pairs used to specify the contents of
the bytes of the packet. The pattern is replicated until it
fills the entire packet.
-T tos
Set the type-of-service in probe packets to the given value
(default zero). The value must be a decimal integer in the range
0 to 255. This option can be used to see if different types-of-
service result in different delays. (If you are not running
4.4bsd, this may be academic since the normal network services
like telnet and ftp don't let you control the TOS). Not all
values of TOS are legal or meaningful - see the IP spec for
definitions. Useful values are probably `-T 16' (low delay) and
`-T 8' (high throughput).
OPERATION
When using ping for fault isolation, it should first be run on the
local host, to verify that the local network interface is up and
running. Then, hosts and gateways further and further away should be
``pinged''. ping sends one ECHO datagram per timeout period, and
prints one line of output for every ECHOREPLY returned (or a warning
if a bounce message is received or no response at all).
If an optional length is specified, it is used as the length of the
data portion of the ICMP ECHO request packet. The default length is
56 data bytes. If an optional count is given, only that number of
requests is sent.
Round-trip times and packet loss statistics are computed. When all
responses have been received or the program times out (with a count
specified), or if the program is terminated with a SIGINT, a brief
summary is displayed. Additional info is printed depending on the
command line flags.
This program is intended for use in network testing, measurement and
management. It should be used primarily for manual fault isolation.
Because of the load it could impose on the network, it is unwise to
use ping during normal operations or from automated scripts.
EXIT STATUS
ping returns a success (zero) exit code in case any valid response was
received, and a failure (nonzero) code if there were none.
WARNING
Specifying both -L and -R simultaneously may not work in all
circumstances, in the sense that it may confuse certain old Cisco
routers. They will clobber their ARP cache, replacing the ethernet
address of the client host with the ethernet address of the next hop
along the route. This will make subsequent normal IP traffic to and
from the client host impossible until the ARP cache is cleared again.
This may take some time. Setting both options is restricted to the
- 4 - Formatted: November 11, 2025
PING(8) PING(8)
990412
superuser, unless the program is compiled with a special compile
switch indicating it is safe.
BROADCAST ADDRESS
Specifying the broadcast address of your local network as the target
for ping yields a nice survey of all active hosts. The internal logic
has been adapted to handle such broadcasts properly. All ping modes
are supported, but a flood ping is restricted to the superuser only.
Fast pings and cisco pings are now timeout-driven. Broadcasts to
different networks usually don't cross gateways. Checking for a
broadcast address is only rudimentary. The -b option may be necessary
in case subnetting is employed.
AUTHOR
Mike Muuss
CO-CONSPIRATORS
Ron Natalie, David Paul Zimmerman, Jeffrey C Honig, Vernon Schryver
Rewritten by Eric Wassenaar, Nikhef-H, <e07@nikhef.nl>
SEE ALSO
netstat(1), ifconfig(8), traceroute(8)
- 5 - Formatted: November 11, 2025