ping command

Purpose

Sends an echo request to a network host.

Syntax

ping [ -n ] [ -r] [ -s PacketSize ] [ -src hostname/IP_addr ] Host [ Count ]

Description

The 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:
  • 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 timeval structure, and enough bytes to fill out 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 host name or Internet address.

By default, the ping command will continue to send echo requests to the display until an Interrupt is received (Ctrl-C). Because of the load that continuous echo requests can place on the system, repeated requests should be used primarily for problem isolation.

Flags

Flag name Description
-n Specifies numeric output only. No attempt is made to look up symbolic names for host addresses.
-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.
-s PacketSize Specifies the number of data bytes to be sent. The default is 56, which translates into 64 ICMP data bytes when combined with the 8 bytes of ICMP header data.
-src hostname/IP_addr Uses the IP address as the source address in outgoing ping packets. On hosts with more than one IP address, the -src flag can be used to force the source address to be something other than the IP address of the interface on which the packet is sent. If the IP address is not one of the machine's interface addresses, an error is returned and nothing is sent.

Parameters

Parameter Description
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.

Examples

  1. To check the network connection to host canopus and specify the number of echo requests to send, enter:
    ping canopus 5

    Information similar to the following is displayed:

    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
  2. To obtain information about host opus and specify the number of data bytes to be sent, enter:
    ping -s 2000 opus

    Information similar to the following is displayed:

    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.



Last updated: Wed, November 18, 2020