ping
Linux Commands - Network Commands

ping

Testing Network Connections.


Purpose of ping


This program will help determine if a computer is online by sending a ICMP ECHO_REQUEST. The expected response is in the form of ICMP ECHO_RESPONSE. In other words, there should be a return response from the machine that was contacted.

{mosimage}

Syntax


ping [options] destination


Example:

ping -c 100 192.168.4.35


The -c option provides the ability to set how many pings should occur before the command stops. In this example the destination will be pinged 100 times as the count follows the option.

{mosimage}

Stopping the ping Command


Turn off the pings using ctrl+c

{mosimage}

ping Options




Options

-c count number of packets to send

-s size determines the size of the packets to be sent

-I Interface which network card to use

-i interval time interval

-f flood continuous stream of packets




Count Option



Example:

ping -c 100 192.168.4.35


The -c option provides the ability to set how many pings should occur before the command stops. In this example the destination will be pinged 100 times as the count follows the option.

{mosimage}

Size Option



Example:

ping -s 100 192.168.4.35


The ICMP header data contains 8 bytes of data and 56 bytes are sent by default so 64 bytes is what is typically sent by ping. The example shows sending 100 bytes and so the added 8 bytes of data will send a total of 108 bytes.

{mosimage}

Interface Option



Example:

ping -I eth1 192.168.4.35



The interface option -I allows the user to choose which network card to use. network interfaces start with eth0 and increase. eth1 is the second network interface.


Interval Option


Example:

ping -i .2 192.168.4.35


The -i option allows a time interval change. the default time interval is 1 second. This interval may be dropped to .2. After that root rights must be used to decrease it further.


Flood Option



Example:

ping -f 192.168.4.35


The -f option floods a destination with continuous pings. Users must be root to run this option. Be careful as there may be serious consequences to using this unwisely