ping command is one of the most commonly used diagnostic tools for network
troubleshooting. Derived from the term "Packet INternet Groper,"
the reachability of a network host and measures the round-trip time for packets
to travel from the source host to the destination.
At its simplest, the syntax for the
ping command is:
ping [OPTIONS] destination
OPTIONSare the command-line options.
destinationis the hostname or IP address of the target system.
Pinging a domain:
This will continuously send ICMP Echo Request packets to
display the round trip time for each packet. To stop, press
CTRL + C.
Specifying Packet Count
To send a specific number of packets, use the
ping -c 5 example.com
This sends 5 packets to
example.com and then stops.
Interval Between Packets
To adjust the interval between individual ping packets, use the
ping -c 5 -i 2 example.com
This sends 5 packets to
example.com with a 2-second interval between packets.
Understanding Packets: ICMP
ICMP or The Internet Control Message Protocol, is a core protocol used by
ping command. It operates at the network layer and is utilized by
network devices, including routers, to send error messages and operational
information. While ICMP is part of the IP layer, it is distinct from more
familiar protocols like TCP and UDP.
ICMP ECHO_REQUEST and ECHO_REPLY:
The ping command works using the ECHO_REQUEST and ECHO_REPLY messages of ICMP.
ECHO_REQUEST: When you execute a ping, your machine sends out an ICMP ECHO_REQUEST packet to the target host. This packet is essentially asking the host, "Are you there?"
ECHO_REPLY: If the target host is reachable and no firewall rules block ICMP messages, it responds with an ICMP ECHO_REPLY. This response confirms to the originating host that the target is active and accepting communications.
Possibility Of Blocking ICMP
For various reasons, including security concerns, a system administrator might want to block incoming ICMP ECHO_REQUEST packets, effectively making the machine un-pingable.
On Linux systems, the
nftables firewall (depending on the distribution and
version) can be configured to drop such packets.
ping Command Options
|Number of packets to send.
|Interval between sending each packet (in seconds). Default is 1 second.
|Time to wait for a response (in seconds). Default is no timeout.
|Specifies the number of data bytes to be sent.
|Set the Time To Live for outgoing packets.
|Flood ping. Sends packets as fast as possible. Must be root to use this option.
|Quiet output. Only display summary at the end.
|Display help information.
ping, you'll see output lines like:
64 bytes from example.com (22.214.171.124): icmp_seq=1 ttl=56 time=15.2 ms
- 64 bytes: This is the size of the packet that was sent.
- example.com (126.96.36.199): The domain and its corresponding IP address.
- icmp_seq=1: The sequence number for the sent packet.
- ttl=56: Time To Live value for the packet.
- time=15.2 ms: The round trip time it took for the packet.
In case of no response, you might see lines like:
Request timeout for icmp_seq 1
ping command is a vital tool for diagnosing network connectivity issues.
Whether you're troubleshooting local network problems or verifying the
accessibility of a remote server,
ping provides quick and insightful feedback.
It's essential to familiarize oneself with its options and output for efficient
network troubleshooting. Always remember to use
ping respectfully, as flooding
a network or server without permission can be deemed as a denial-of-service
What Can You Do Next 🙏😊
If you liked the article, consider subscribing to Cloudaffle, my YouTube Channel, where I keep posting in-depth tutorials and all edutainment stuff for software developers.