The ping command is handy utility command to quickly test network connections. It sends a packet of data to a specific IP address or hostname and shows how long it took to transmit that data with severeal additional response information.
General syntax for
Specify the number of packets
ping -c [number] [IP-Address]
-c option to have the ping command automatically stop after a certain number of packets have been sent.
Example: Let’s stop sending packets after 5 replies. And specifying 127.0.0.1 as the IP address
Check Localhost network
If you’re having trouble connecting to a remote computer or website, ping the localhost to ensure you’re connected.
Example: Let’s type this command to test the network connection.
Send pings only for a limited period of time
ping -i [number] [IP-Address]
-i option sets the timeout interval in seconds before each packet is sent.
Example: Sending ICMP packets with an interval of 5 seconds to the IP address 127.0.0.1.
Flood ping to target host
ping -f [IP-address]
-f option is used to run the flood ping. This will help you test the performance of your network under heavy load.
Example: Flood pinging IP address 127.0.0.1.
Change ping packet size
ping -s [number] [IP-Address]
-s option to increase the default packet size, you can send light and heavy packets.
Example: Let’s increase the packet size to 1000 bytes and send them to the IP address 127.0.0.1.
Display only the summary lines
ping -q [IP-Address]
-q option outputs a single line with the regular ping information, followed by the statistics.
Example: Getting only summary information about the IP address 127.0.0.1.
Set Time Limit for receiving packages
ping -w [seconds] [IP-Address]
This option stops receiving
ping output after a certain length of time.
Example: Entering the
ping -w 10 127.0.0.1 command to stop printing
ping output after 10 seconds.