One of the earliest parts of network troubleshooting is sending test packets between two systems. This is done using a TCP/IP utility called ping. The ping command will generate a response request from the sending computer and should receive a reply from the destination computer.
Possible outcomes of the ping command include:
- Reply from [host]: The connection was successful.
- Destination unreachable: The source computer cannot find a path to the destination. This often indicates the problem is with the source computer.
- Timeout: The request reached the destination computer but a response did not return to the source computer before the source computer timed out. This often indicates the problem is with the destination computer.
Although using ping is one of the earliest steps in the network troubleshooting process, it only tells you that something is wrong—not what is wrong.
Syntax
The syntax of the ping command is:
# ping [options] {destination}
The {destination} can be an IP address, such as 192.168.1.1, or it can be a hostname, such as server01.
ping Command Options
Some common ping command options include:
-c — only send a specified number of pinging attempts. By default, Linux sends a continuous ping until interrupted with Ctrl+C.
-v — specify verbose output.
If you encounter the below error while running the ping command:
ping: command not found
you may try installing the below package as per your choice of distribution:
OS Distribution | Command |
---|---|
Debian | apt-get install inetutils-ping |
Ubuntu | apt-get install inetutils-ping |
Alpine | apk add iputils |
Arch Linux | pacman -S iputils |
Kali Linux | apt-get install inetutils-ping |
CentOS | yum install iputils |
Fedora | dnf install iputils |
Raspbian | apt-get install inetutils-ping |
ping Command Examples
1. To send ICMP request to mentioned host:
# ping 192.168.200.10
2. To have the audible ping:
# ping -a 192.168.200.10
3. To ping for particular number of counts:
# ping -c 10 192.168.27.100
4. For flood ping:
# ping -f 192.168.27.100
5. To set the interval:
# ping -i 10 192.168.27.100
6. To ping particular iterface:
# ping -I eth0 192.168.27.100
7. To sent specified number of packets without waiting for reply:
# ping -l 10 192.168.27.100
8. To get the numerical output only:
# ping -n 192.168.27.100
9. To suppress the output:
# ping -q
10. To record the route:
# ping -R
11. To bypass the routing table:
# ping -r
12. To specifies the number of data bytes to be sent:
# ping -s 1024
13. To set the IP Time to Live:
# ping -t 10
14. To Set special IP timestamp options:
# ping -T
15. To Select Path MTU Discovery strategy:
# ping -M hint
16. To Print full user-to-user latency:
# ping -U
17. To to set to verbose mode:
# ping -v
18. To show the version info:
# ping -V
19. To set the timeout:
# ping -w 10
20. To time to wait for a response:
# ping -W 10