ping Command
Purpose
Sends an echo request to a network host.
Syntax
ping [ -d] [ -D ] [ -n] [ -q] [ -r] [ -v] [ -R] [ -a addr_family ] [ -c Count ] [ -w timeout ] [ -f| -i Wait ] [ -l Preload ] [ -p Pattern ] [ -s PacketSize ] [ -S hostname/IP addr ] [ -L ] [ -I a.b.c.d. ] [ -o interface ] [ -T ttl ] [-E Interface_name | Source_Hostname | Source_IP_address] Host [ PacketSize ] [ Count ]
Description
The /usr/sbin/ping command sends an Internet Control Message Protocol (ICMP) ECHO_REQUEST to obtain an ICMP ECHO_RESPONSE from a host or gateway. The ping command is useful for the following functions:
- Determining the status of the network and various foreign hosts.
- Tracking and isolating hardware and software problems.
- Testing, measuring, and managing networks.
If the host is operational and on the network, it responds to the echo.
Each echo request contains an Internet Protocol (IP) and ICMP header, followed by a ping PID and a
timeval
structure, and enough bytes to complete the packet. The default is to continuously
send echo requests until an Interrupt is received (Ctrl-C).
The ping command sends one datagram per second and
prints one line of output for every response received. The ping command
calculates round-trip times and packet loss statistics, and displays a brief summary on completion.
The ping command completes when the program times out or on receipt of a
SIGINT
signal. The Host parameter is either a valid hostname or Internet
address.
By default, the ping command continues to send echo
requests to the display until an Interrupt is received (Ctrl-C)
. The Interrupt key
can be changed by using the stty command.
Because of the load that continuous echo requests can place on the system, repeated requests must be used primarily for problem isolation.
Flags
Item | Description |
---|---|
-c Count | Specifies the number of echo requests, as indicated by the Count variable, to be sent (and received). |
-w timeout | This option works only with the -c option. It causes ping to wait for a maximum of 'timeout' seconds for a reply (after sending the last packet). |
-d | Starts socket-level debugging. |
-D | This option causes a hex dump to standard output of ICMP ECHO_REPLY packets. |
-E Interface_name | Source_Hostname | Source_IP_address | Sends or receives ping packets over specific interface for both IPv4 and IPv6
protocols. When you specify an interface name, a source hostname, or a source IP address that is not
one of the machine's interface addresses, an error is returned and no ping packets are sent. If you
specify an interface name with the -E flag, by default, the number of echo
requests (-c
Count) is set to a value of 5. Notes:
|
-f | Specifies flood-ping option. The -f flag "floods" or outputs packets as
fast as they come back or 100 times per second, whichever is more. For every ECHO_REQUEST sent, a.
(period) is printed, while for every ECHO_REPLY received, a backspace is printed. This provides a
rapid display of how many packets are being dropped. Only the root user can use this option.
Note: Use this flag with caution. Flood pinging is only permitted by the root user. The
-f flag is incompatible with the -i
Wait flag.
|
-I a.b.c.d | Specifies that the interface specified by a.b.c.d is to be used for outgoing IPv4 multicasts. The -I flag is an uppercase i. |
-o interface | Specifies that interface is to be used for outgoing IPv6 multicasts. The interface is specified in the form 'en0', 'tr0', and so on. |
-i Wait | Waits the number of seconds specified by the Wait variable between the sending of each packet. The default is to wait for one second between each packet. This option is incompatible with the -f flag. |
-L | Disables local loopback for multicast pings. |
-l Preload | Sends the number of packets that are specified by the Preload variable as fast as possible before falling into normal mode of behavior (one per second). The -l flag is a lowercase l. |
-n | Specifies numeric output only. No attempt is made to look up symbolic names for host addresses. |
-p Pattern | Specifies up to 16 'pad' bytes to complete the packet you send. This is useful for
diagnosing data-dependent problems in a network. For example, -p ff fills the
packet with all 1's. |
-q | Specifies quiet output. Nothing is displayed except the summary lines at startup time and when finished. |
-r | Bypasses the routing tables and sends directly to a host on an attached network. If the Host is not on a directly connected network, the ping command generates an error message. This option can be used to ping a local host through an interface that no longer has a route through it. |
-R | Specifies record route option. The -R flag includes the RECORD_ROUTE
option in the ECHO_REQUEST packet and displays the route buffer on returned packets. Note: The IP
header is only large enough for nine such routes. Also, many hosts and gateways ignore this
option.
|
-a addr_family | Maps the destination address of the ICMP packets to IPv6 format if addr_family is equal to "inet6". |
-s PacketSize | Specifies the number of data bytes to be sent. The default is 56, which converts into 64 ICMP data bytes when combined with the 8 bytes of ICMP header data. |
-S hostname/IP addr | Uses the IP address as the source address in outgoing ping packets. On hosts
with more than one IP address, the -S flag can be used to send or receive ping
packets by using a specific source IP address. If the IP address is not one of the machine's
interface addresses, an error is returned and nothing is sent. Note: You can use the
-S flag to send or receive the ping packet by using a specific source IP
address, but the -S flag does not guarantee to send or receive ping packet over
specific interface. Instead, use -E flag that ensures to send or receive ping
packet over specific interface.
|
-T ttl | Specifies that the time to live for a multicast packet is ttl seconds. |
-v | Requests verbose output, which lists ICMP packets that are received in addition to echo responses. |
Parameters
Item | Description |
---|---|
PacketSize | Specifies the number of data bytes to be sent. The default is 56, which converts into 64 ICMP data bytes when combined with the 8 bytes of ICMP header data. This parameter is included for compatibility with previous versions of the ping command. |
Count | Specifies the number of echo requests to be sent (and received). This parameter is included for compatibility with previous versions of the ping command. |
Security
- Attention RBAC users
- Attention RBAC users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in Security. For a list of privileges and the authorizations that are associated with this command, see the lssecattr command or the getcmdattr subcommand.
Examples
- To check the network connection to the host
canopus
and specify the number of echo requests to send, enter:
ORping -c 5 canopus
Information similar to the following is displayed:ping canopus 56 5
PING canopus.austin.century.com: (128.116.1.5): 56 data bytes 64 bytes from 128.116.1.5: icmp_seq=0 ttl=255 time=2 ms 64 bytes from 128.116.1.5: icmp_seq=1 ttl=255 time=2 ms 64 bytes from 128.116.1.5: icmp_seq=2 ttl=255 time=3 ms 64 bytes from 128.116.1.5: icmp_seq=3 ttl=255 time=2 ms 64 bytes from 128.116.1.5: icmp_seq=4 ttl=255 time=2 ms ----canopus.austin.century.com PING Statistics---- 5 packets transmitted, 5 packets received, 0% packet loss round-trip min/avg/max = 2/2/3 ms
- To get information about host
lear
and start socket-level debugging, enter:
Information similar to the following is displayed:ping -d lear
PING lear.austin.century.com: (128.114.4.18) 56 data bytes 64 bytes from 128.114.4.18: icmp_seq=0 ttl=255 time=6 ms 64 bytes from 128.114.4.18: icmp_seq=1 ttl=255 time=17 ms 64 bytes from 128.114.4.18: icmp_seq=2 ttl=255 time=6 ms 64 bytes from 128.114.4.18: icmp_seq=3 ttl=255 time=6 ms 64 bytes from 128.114.4.18: icmp_seq=4 ttl=255 time=6 ms ^C ----lear.austin.century.com PING Statistics ---- 5 packets transmitted, 5 packets received, 0% packet loss round-trip min/avg/max = 6/8/17 ms
Note: The output is repeated until an Interrupt (Ctrl-C) is received. - To obtain information about host
opus
and specify the number of data bytes to be sent, enter:
ORping -s 2000 opus
Information similar to the following is displayed:ping opus 2000
PING opus.austin.century.com: (129.35.34.234): 2000 data bytes 2008 bytes from 129.35.34.234: icmp_seq=0 ttl=255 time=20 ms 2008 bytes from 129.35.34.234: icmp_seq=1 ttl=255 time=19 ms 2008 bytes from 129.35.34.234: icmp_seq=2 ttl=255 time=20 ms 2008 bytes from 129.35.34.234: icmp_seq=3 ttl=255 time=20 ms 2008 bytes from 129.35.34.234: icmp_seq=4 ttl=255 time=20 ms 2008 bytes from 129.35.34.234: icmp_seq=5 ttl=255 time=19 ms 2008 bytes from 129.35.34.234: icmp_seq=6 ttl=255 time=19 ms ^C ----opus.austin.century.com PING Statistics---- 7 packets transmitted, 7 packets received, 0% packet loss round-trip min/avg/max = 19/19/20 ms
Note: The output is repeated until an Interrupt (Ctrl-C) is received. - To invoke the flood-ping option to the host
stlopnor
, enter:
Information similar to the following is displayed:ping -f stlopnor
Ping stlopnor.austin.century.com: (129.35.34.234): 56 data bytes .^C ----stlopnor.austin.century.com PING Statistics ---- 1098 packets transmitted, 1097 packets received, 0% packet loss round-trip min/avg/max = 4/4/11
Note: The output is repeated until an Interrupt (Ctrl-C) is received. - To specify an interval of five seconds between packets sent to the host
opus
, enter:
Information similar to the following is displayed:ping -i5 opus
PING opus.austin.century.com: (129.35.34.234): 56 data bytes 64 bytes from 129.35.34.234: icmp_seq=0 ttl=255 time=5 ms 64 bytes from 129.35.34.234: icmp_seq=1 ttl=255 time=5 ms 64 bytes from 129.35.34.234: icmp_seq=2 ttl=255 time=6 ms ^C ----opus.austin.century.com PING Statistics---- 3 packets transmitted, 3 packets received, 0% packet loss round-trip min/avg/max = 5/5/6 ms
Note: The output is repeated until an Interrupt (Ctrl-C) is received. - To send the number of packets that are specified by the Preload variable as
fast as possible before falling into normal mode of behavior to the host
opus
, enter:
Information similar to the following is displayed:ping -l 10 opus
PING opus.austin.century.com: (129.35.34.234): 56 data bytes 64 bytes from 129.35.34.234: icmp_seq=0 ttl=255 time=9 ms 64 bytes from 129.35.34.234: icmp_seq=1 ttl=255 time=11 ms 64 bytes from 129.35.34.234: icmp_seq=2 ttl=255 time=16 ms 64 bytes from 129.35.34.234: icmp_seq=3 ttl=255 time=22 ms 64 bytes from 129.35.34.234: icmp_seq=4 ttl=255 time=26 ms 64 bytes from 129.35.34.234: icmp_seq=5 ttl=255 time=27 ms 64 bytes from 129.35.34.234: icmp_seq=6 ttl=255 time=30 ms 64 bytes from 129.35.34.234: icmp_seq=7 ttl=255 time=31 ms 64 bytes from 129.35.34.234: icmp_seq=8 ttl=255 time=33 ms 64 bytes from 129.35.34.234: icmp_seq=9 ttl=255 time=35 ms 64 bytes from 129.35.34.234: icmp_seq=10 ttl=255 time=36 ms 64 bytes from 129.35.34.234: icmp_seq=11 ttl=255 time=6 ms 64 bytes from 129.35.34.234: icmp_seq=12 ttl=255 time=6 ms 64 bytes from 129.35.34.234: icmp_seq=13 ttl=255 time=6 ms 64 bytes from 129.35.34.234: icmp_seq=14 ttl=255 time=7 ms 64 bytes from 129.35.34.234: icmp_seq=15 ttl=255 time=6 ms ^C ----opus.austin.century.com PING Statistics---- 16 packets transmitted, 16 packets received, 0% packet loss round-trip min/avg/max = 6/19/36 ms
Note: The output is repeated until an Interrupt (Ctrl-C) is received. - To diagnose data-dependent problems in a network, enter:
This command sends packets with a pad-pattern of all 1's to hostping -p ff opus
opus
. Information similar to the following is displayed:PATTERN: 0xff PING opus.austin.century.com: (129.35.34.234): 56 data bytes 64 bytes from 129.35.34.234: icmp_seq=0 ttl=255 time=5 ms 64 bytes from 129.35.34.234: icmp_seq=1 ttl=255 time=5 ms 64 bytes from 129.35.34.234: icmp_seq=2 ttl=255 time=5 ms 64 bytes from 129.35.34.234: icmp_seq=3 ttl=255 time=6 ms 64 bytes from 129.35.34.234: icmp_seq=4 ttl=255 time=5 ms ^C ----opus.austin.century.com PING Statistics---- 5 packets transmitted, 5 packets received, 0% packet loss round-trip min/avg/max = 5/5/6 ms
Note: The output is repeated until an Interrupt (Ctrl-C) is received. - To specify quiet output, enter:
Only summary information similar to the following sample is displayed:ping -q bach
PING bach.austin.century.com: (129.35.34.234): 56 data bytes ^C ----bach.austin.century.com PING Statistics---- 5 packets transmitted, 5 packets received, 0% packet loss round-trip min/avg/max = 5/5/8 ms
Note: The output is repeated until an Interrupt (Ctrl-C) is received. - To send or receive ping packets over a specific interface, enter the following
command:
An output similar to the following example is displayed:ping -E en1 2020:1234:5678:9122:2c6f:57ff:fe6b:8b02
Using Source Address 2020:1234:5678:9122:2c6f:57ff:3e6b:58 PING 2020:1234:5678:9122:2c6f:57ff:fe6b:8b02: (2020:1234:5678:9122:2c6f:57ff:fe6b:8b02): 56 data bytes 64 bytes from 2020:1234:5678:9122:2c6f:57ff:fe6b:8b02: icmp_seq=0 ttl=64 time=1.462 ms 64 bytes from 2020:1234:5678:9122:2c6f:57ff:fe6b:8b02: icmp_seq=1 ttl=64 time=0.917 ms 64 bytes from 2020:1234:5678:9122:2c6f:57ff:fe6b:8b02: icmp_seq=2 ttl=64 time=1.187 ms 64 bytes from 2020:1234:5678:9122:2c6f:57ff:fe6b:8b02: icmp_seq=3 ttl=64 time=1.105 ms 64 bytes from 2020:1234:5678:9122:2c6f:57ff:fe6b:8b02: icmp_seq=4 ttl=64 time=1.114 ms --- 2020:1234:5678:9122:2c6f:57ff:fe6b:8b02 ping statistics --- 5 packets transmitted, 5 packets received, 0% packet loss round-trip min/avg/max = 0/0/1 ms