Linux Commands | Network | ping Check Whether a Remote Host Is Reachable

ping Command

Checks whether a remote host is reachable.

Usage

ping (option) [IP address or domain to check]

Options:

  • -c (count): Number of pings to send
  • -i (interval): Interval between pings
  • -s (size): Ping packet size (maximum 65507)
  • -f (fast): Maximum speed

ping Command Example

In the example below, ping is sent 3 times.

[devkuma@localhost ~]$ ping -c 3 www.google.com
PING www.google.com (172.217.24.196): 56 data bytes
64 bytes from 172.217.24.196: icmp_seq=0 ttl=49 time=68.258 ms
64 bytes from 172.217.24.196: icmp_seq=1 ttl=49 time=70.593 ms
64 bytes from 172.217.24.196: icmp_seq=2 ttl=49 time=68.935 ms

--- www.google.com ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 68.258/69.262/70.593/0.981 ms

ping Traffic

Default ping value: 8 bytes
Maximum ping value: 65515 bytes (65507 + 8)

Advanced ping Settings

Block ping (block ICMP)

$ echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all

Allow ping (allow ICMP)

$ echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all