-->
  • Recent Articles

    Dozen of ping command examples to help you troubleshoot

     Ping is a simple, widely used, cross-platform networking utility for testing if a host is reachable on annetwork. It works by sending a series of Internet Control Message Protocol (ICMPECHO_REQUEST messages to the target host and waiting for an ICMP echo reply (or ECHO_RESPONSE). ICMP is assigned Protocol Number 1 in the IP suite according to IANA.org

    You can run a ping test in order to establish if your computer can communicate with another computer.

    PING Failure:

    C:\Users\MANASTRI>ping 192.168.56.107 -t
    
    Pinging 192.168.56.107 with 32 bytes of data:
    Request timed out.
    Request timed out.
    Request timed out.
    Request timed out.
    
    Ping statistics for 192.168.56.107:
        Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
    Control-C
    ^C
    C:\Users\MANASTRI>

    PING Passed :

    C:\Users\MANASTRI>ping 192.168.56.107 -t
    
    Pinging 192.168.56.107 with 32 bytes of data:
    Reply from 192.168.56.107: bytes=32 time<1ms TTL=64
    Reply from 192.168.56.107: bytes=32 time<1ms TTL=64
    Reply from 192.168.56.107: bytes=32 time<1ms TTL=64
    Reply from 192.168.56.107: bytes=32 time<1ms TTL=64
    
    Ping statistics for 192.168.56.107:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 0ms, Maximum = 0ms, Average = 0ms
    Control-C
    ^C
    C:\Users\MANASTRI>

    Continuos ping in Windows:

    In windows PING utility exits after 4 ping requests. To run a continuos ping to the target run the command with "-t" option.

    Regular:

    C:\Users\MANASTRI>ping 192.168.56.107
    
    Pinging 192.168.56.107 with 32 bytes of data:
    Reply from 192.168.56.107: bytes=32 time<1ms TTL=64
    Reply from 192.168.56.107: bytes=32 time<1ms TTL=64
    Reply from 192.168.56.107: bytes=32 time<1ms TTL=64
    Reply from 192.168.56.107: bytes=32 time<1ms TTL=64
    
    Ping statistics for 192.168.56.107:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 0ms, Maximum = 0ms, Average = 0ms
    
    C:\Users\MANASTRI>

    With "-t" option:

    C:\Users\MANASTRI>ping 192.168.56.107 -t
    
    Pinging 192.168.56.107 with 32 bytes of data:
    Reply from 192.168.56.107: bytes=32 time<1ms TTL=64
    Reply from 192.168.56.107: bytes=32 time<1ms TTL=64
    Reply from 192.168.56.107: bytes=32 time<1ms TTL=64
    Reply from 192.168.56.107: bytes=32 time<1ms TTL=64
    Reply from 192.168.56.107: bytes=32 time<1ms TTL=64
    Reply from 192.168.56.107: bytes=32 time<1ms TTL=64
    Reply from 192.168.56.107: bytes=32 time<1ms TTL=64
    Reply from 192.168.56.107: bytes=32 time<1ms TTL=64
    
    Ping statistics for 192.168.56.107:
        Packets: Sent = 8, Received = 8, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 0ms, Maximum = 0ms, Average = 0ms
    Control-C
    ^C
    C:\Users\MANASTRI>

    Simple ping:

    You can run a simple ping test to see whether the targe host www.devopszones.com is reachable or not. 

    C:\Users\MANASTRI>ping devopszones.com
    
    Pinging devopszones.com [216.239.34.21] with 32 bytes of data:
    Reply from 216.239.34.21: bytes=32 time=46ms TTL=112
    Reply from 216.239.34.21: bytes=32 time=46ms TTL=112
    Reply from 216.239.34.21: bytes=32 time=47ms TTL=112
    Reply from 216.239.34.21: bytes=32 time=46ms TTL=112
    
    Ping statistics for 216.239.34.21:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 46ms, Maximum = 47ms, Average = 46ms
    
    C:\Users\MANASTRI>

    From the results of the above command, the ping was successful and there were no packets lost. One important thing to take note of, in a ping test output is the time at the end of each ping reply, Which define your latency.

    Restrict Ping Packets:

    You can specify the number of ECHO_REQUEST’s to be sent after which ping exits, using the "-c" flag.

    root@salt-master ~]# ping -c 10 devopszones.com
    PING devopszones.com (216.239.32.21) 56(84) bytes of data.
    64 bytes from any-in-2015.1e100.net (216.239.32.21): icmp_seq=1 ttl=111 time=46.9 ms
    64 bytes from any-in-2015.1e100.net (216.239.32.21): icmp_seq=2 ttl=111 time=48.1 ms
    64 bytes from any-in-2015.1e100.net (216.239.32.21): icmp_seq=3 ttl=111 time=49.3 ms
    64 bytes from any-in-2015.1e100.net (216.239.32.21): icmp_seq=4 ttl=111 time=50.9 ms
    64 bytes from any-in-2015.1e100.net (216.239.32.21): icmp_seq=5 ttl=111 time=47.5 ms
    64 bytes from any-in-2015.1e100.net (216.239.32.21): icmp_seq=6 ttl=111 time=85.9 ms
    64 bytes from any-in-2015.1e100.net (216.239.32.21): icmp_seq=7 ttl=111 time=47.9 ms
    64 bytes from any-in-2015.1e100.net (216.239.32.21): icmp_seq=8 ttl=111 time=50.4 ms
    64 bytes from any-in-2015.1e100.net (216.239.32.21): icmp_seq=9 ttl=111 time=47.7 ms
    64 bytes from any-in-2015.1e100.net (216.239.32.21): icmp_seq=10 ttl=111 time=50.0 ms
    
    --- devopszones.com ping statistics ---
    10 packets transmitted, 10 received, 0% packet loss, time 9022ms
    rtt min/avg/max/mdev = 46.975/52.523/85.979/11.227 ms
    [root@salt-master ~]#
    Set Interval between Ping Request:

    The "-i" flag enables you to set interval in seconds between sending each packet, the default value is one second.

    [root@salt-master ~]# ping -i 5 -c 10 devopszones.com
    PING devopszones.com (216.239.36.21) 56(84) bytes of data.
    64 bytes from any-in-2415.1e100.net (216.239.36.21): icmp_seq=1 ttl=111 time=51.1 ms
    64 bytes from any-in-2415.1e100.net (216.239.36.21): icmp_seq=2 ttl=111 time=52.3 ms
    64 bytes from any-in-2415.1e100.net (216.239.36.21): icmp_seq=3 ttl=111 time=51.5 ms
    64 bytes from any-in-2415.1e100.net (216.239.36.21): icmp_seq=4 ttl=111 time=52.8 ms
    64 bytes from any-in-2415.1e100.net (216.239.36.21): icmp_seq=5 ttl=111 time=51.7 ms
    64 bytes from any-in-2415.1e100.net (216.239.36.21): icmp_seq=6 ttl=111 time=51.3 ms
    64 bytes from any-in-2415.1e100.net (216.239.36.21): icmp_seq=7 ttl=111 time=52.8 ms
    64 bytes from any-in-2415.1e100.net (216.239.36.21): icmp_seq=8 ttl=111 time=53.7 ms
    64 bytes from any-in-2415.1e100.net (216.239.36.21): icmp_seq=9 ttl=111 time=49.9 ms
    64 bytes from any-in-2415.1e100.net (216.239.36.21): icmp_seq=10 ttl=111 time=50.7 ms
    
    --- devopszones.com ping statistics ---
    10 packets transmitted, 10 received, 0% packet loss, time 45052ms
    rtt min/avg/max/mdev = 49.964/51.840/53.793/1.088 ms
    [root@salt-master ~]#
    Ping a broadcast:

    You can ping a broadcast IP using the "-b" flag.

    [root@salt-master ~]# ping -b 192.168.56.255
    WARNING: pinging broadcast address
    PING 192.168.56.255 (192.168.56.255) 56(84) bytes of data.
    ^C
    --- 192.168.56.255 ping statistics ---
    8 packets transmitted, 0 received, 100% packet loss, time 7010ms
    
    [root@salt-master ~]#
    Limit TTL value:

    It will Set the IP Time to Live.
    [root@salt-master ~]# ping -t 50 devopszones.com
    PING devopszones.com (216.239.38.21) 56(84) bytes of data.
    64 bytes from any-in-2615.1e100.net (216.239.38.21): icmp_seq=1 ttl=111 time=47.5 ms
    64 bytes from any-in-2615.1e100.net (216.239.38.21): icmp_seq=2 ttl=111 time=49.3 ms
    64 bytes from any-in-2615.1e100.net (216.239.38.21): icmp_seq=3 ttl=111 time=47.3 ms
    64 bytes from any-in-2615.1e100.net (216.239.38.21): icmp_seq=4 ttl=111 time=46.5 ms
    64 bytes from any-in-2615.1e100.net (216.239.38.21): icmp_seq=5 ttl=111 time=49.4 ms
    64 bytes from any-in-2615.1e100.net (216.239.38.21): icmp_seq=6 ttl=111 time=48.5 ms
    64 bytes from any-in-2615.1e100.net (216.239.38.21): icmp_seq=7 ttl=111 time=50.3 ms
    ^C
    --- devopszones.com ping statistics ---
    8 packets transmitted, 7 received, 12% packet loss, time 7016ms
    rtt min/avg/max/mdev = 46.544/48.440/50.342/1.278 ms
    [root@salt-master ~]#
    Do a Flood Ping:

    To test the response of your network during high load , you can run a “flood ping” which sends requests as fast as possible, using the "-f" flag.

    [root@salt-master ~]# ping -f devopszones.com
    PING devopszones.com (216.239.36.21) 56(84) bytes of data.
    .................^C
    --- devopszones.com ping statistics ---
    3605 packets transmitted, 3588 received, 0% packet loss, time 49578ms
    rtt min/avg/max/mdev = 48.846/51.805/325.075/11.851 ms, pipe 21, ipg/ewma 13.756/50.419 ms
    [root@salt-master ~]#
    
    Set ping Packet Size:

    You set a ping payload , i.e number of bytes using the "-s" option, which will result in a total packet size of value provided plus 8 extra bytes for the ICMP header.

    [root@salt-master ~]# ping -s 512  devopszones.com
    PING devopszones.com (216.239.38.21) 512(540) bytes of data.
    76 bytes from any-in-2615.1e100.net (216.239.38.21): icmp_seq=1 ttl=111 (truncated)
    76 bytes from any-in-2615.1e100.net (216.239.38.21): icmp_seq=2 ttl=111 (truncated)
    76 bytes from any-in-2615.1e100.net (216.239.38.21): icmp_seq=3 ttl=111 (truncated)
    76 bytes from any-in-2615.1e100.net (216.239.38.21): icmp_seq=4 ttl=111 (truncated)
    76 bytes from any-in-2615.1e100.net (216.239.38.21): icmp_seq=5 ttl=111 (truncated)
    ^C
    --- devopszones.com ping statistics ---
    5 packets transmitted, 5 received, 0% packet loss, time 4009ms
    rtt min/avg/max/mdev = 48.496/48.937/49.398/0.373 ms
    [root@salt-master ~]#
    Set ping Preload:

    Ping will send preload packets without waiting for an reply.
    [root@salt-master ~]# ping -l 5 www.google.com
    PING www.google.com (142.250.182.132) 56(84) bytes of data.
    64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=1 ttl=110 time=48.7 ms
    64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=2 ttl=110 time=50.3 ms
    64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=3 ttl=110 time=49.5 ms
    64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=4 ttl=110 time=49.1 ms
    64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=5 ttl=110 time=48.8 ms
    64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=6 ttl=110 time=48.6 ms
    ^C
    --- www.google.com ping statistics ---
    6 packets transmitted, 6 received, 0% packet loss, time 1003ms
    rtt min/avg/max/mdev = 48.697/49.215/50.377/0.647 ms, pipe 5
    [root@salt-master ~]#
    Set a Ping Timeout:

    Specify a timeout, in seconds, before ping exits regardless of how many packets have been sent or received. In this case ping does not stop after count packet are sent, it waits either for deadline expire or until count probes are answered or for some error notification from network. It can be achieved with a "-w" flag.

    [root@salt-master ~]# ping -w 10 www.google.com
    PING www.google.com (142.250.182.132) 56(84) bytes of data.
    64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=1 ttl=110 time=48.7 ms
    64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=2 ttl=110 time=50.0 ms
    64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=3 ttl=110 time=50.9 ms
    64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=4 ttl=110 time=48.4 ms
    64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=5 ttl=110 time=49.4 ms
    64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=6 ttl=110 time=49.7 ms
    64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=7 ttl=110 time=49.4 ms
    64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=8 ttl=110 time=50.5 ms
    64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=9 ttl=110 time=49.3 ms
    64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=10 ttl=110 time=49.0 ms
    
    --- www.google.com ping statistics ---
    10 packets transmitted, 10 received, 0% packet loss, time 9019ms
    rtt min/avg/max/mdev = 48.453/49.560/50.911/0.755 ms
    [root@salt-master ~]#
    
    Print Timestamp with Ping:

     Print timestamp (unix time + microseconds as in gettimeofday) before each line. It can be achieved with a "-D" flag.

    [root@salt-master ~]#  ping -D www.google.com
    PING www.google.com (142.250.182.132) 56(84) bytes of data.
    [1629467313.207957] 64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=1 ttl=110 time=48.5 ms
    [1629467314.196776] 64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=2 ttl=110 time=49.9 ms
    [1629467315.197988] 64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=3 ttl=110 time=49.6 ms
    [1629467316.198495] 64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=4 ttl=110 time=48.4 ms
    [1629467317.203538] 64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=5 ttl=110 time=51.4 ms
    [1629467318.208630] 64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=6 ttl=110 time=54.3 ms
    ^C
    --- www.google.com ping statistics ---
    6 packets transmitted, 6 received, 0% packet loss, time 5009ms
    rtt min/avg/max/mdev = 48.475/50.400/54.337/2.032 ms
    [root@salt-master ~]#

    Ping Using a Specific Interface:

     Interface is either an address, or an interface name.  If interface is an address, it sets source address to specified interface address.  If interface in an interface name, it sets source  interface to specified interface.   It can be achieved with a "-I" flag.

     ping -I <interface name> www.google.com

    Ping using "enp0s3" interface.

    [root@salt-master ~]#  ping -I enp0s3  www.google.com
    PING www.google.com (142.250.182.132) from 10.0.2.15 enp0s3: 56(84) bytes of data.
    64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=1 ttl=110 time=48.4 ms
    64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=2 ttl=110 time=50.2 ms
    64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=3 ttl=110 time=48.5 ms
    64 bytes from maa05s22-in-f4.1e100.net (142.250.182.132): icmp_seq=4 ttl=110 time=50.7 ms
    ^C
    --- www.google.com ping statistics ---
    4 packets transmitted, 4 received, 0% packet loss, time 3007ms
    rtt min/avg/max/mdev = 48.483/49.497/50.767/1.023 ms
    [root@salt-master ~]#

    Ping using "enp0s8" interface.

    [root@salt-master ~]#  ping -I enp0s8  www.google.com
    PING www.google.com (142.250.182.132) from 192.168.56.107 enp0s8: 56(84) bytes of data.
    ^C
    --- www.google.com ping statistics ---
    8 packets transmitted, 0 received, 100% packet loss, time 7002ms
    
    [root@salt-master ~]#
    If you like this article, then please do share.

    No comments