ping: Send ICMP packets to network hosts to verify reachability
August 9th, 2024 12:22 PM Mr. Q Categories: Command
Command: ping
Used to check the connectivity to a network host by sending ICMP Echo Request packets and measuring the response time. This command helps determine if a host is reachable over the network.
Sample Command and Output:
$ ping example.com
PING example.com (93.184.216.34) 56(84) bytes of data.
64 bytes from example.com (93.184.216.34): icmp_seq=1 ttl=55 time=14.1 ms
64 bytes from example.com (93.184.216.34): icmp_seq=2 ttl=55 time=13.9 ms
64 bytes from example.com (93.184.216.34): icmp_seq=3 ttl=55 time=14.2 ms
Description:
ping example.com
: Sends ICMP Echo Request packets toexample.com
and displays the time it takes to receive a response. Each response includes the sequence number (icmp_seq
), the time-to-live (ttl
), and the round-trip time (time
).
Sample Command and Output:
$ ping -c 4 example.com
PING example.com (93.184.216.34) 56(84) bytes of data.
64 bytes from example.com (93.184.216.34): icmp_seq=1 ttl=55 time=14.1 ms
64 bytes from example.com (93.184.216.34): icmp_seq=2 ttl=55 time=13.9 ms
64 bytes from example.com (93.184.216.34): icmp_seq=3 ttl=55 time=14.2 ms
64 bytes from example.com (93.184.216.34): icmp_seq=4 ttl=55 time=14.0 ms
--- example.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 13.897/14.057/14.208/0.141 ms
Description:
ping -c 4 example.com
: Sends 4 ICMP Echo Request packets toexample.com
and then stops. The-c
option specifies the number of packets to send. The output includes statistics such as packet loss and round-trip time.
Additional Usage Examples:
ping -t 30 example.com
: Sends ICMP Echo Request packets indefinitely until interrupted (on Windows,-t
for continuous; on Unix-like systems, omit-c
to ping indefinitely).ping -i 2 example.com
: Sends packets at a 2-second interval (where-i
specifies the interval).
Description:
ping -i 2 example.com
: Adjusts the interval between each packet to 2 seconds.