Skip to content

ping

11 commands

Sends ICMP echo requests to test reachability and measure round-trip time.

  • networking
  • ICMP
  • connectivity

Install ping

sudo apt install iputils-ping

Basics6

ping <host>

Sends echo requests until Ctrl-C and reports latency and loss.

Link
ping -c <n> <host>

Stops after n packets — what you want in scripts.

Link
ping -i <seconds> <host>

Changes the interval; below 0.2 s needs root.

Link
ping -W <seconds> -c 1 <host>

Waits at most n seconds for a reply.

Link
ping -q -c <n> <host>

Prints only the summary.

Link
ping -6 <host>

Forces IPv6.

Link

Diagnostics5

ping -s <bytes> <host>

Sets payload size. With -M do (do not fragment) this finds the path MTU: 1472 + 28 bytes of headers = 1500.

Link
ping -D <host>

Prints a timestamp before each line.

Link
ping -c 1 <host>

Reads the TTL in the reply to guess the OS: about 64 for Linux and macOS, 128 for Windows, 255 for network gear.

Link
ping -b <broadcast>

Pings a broadcast address; most modern hosts ignore it.

Link
for i in $(seq 1 254); do ping -c1 -W1 <prefix>.$i | grep "bytes from" & done; wait

A quick ping sweep with nothing but bash — useful on a foothold without nmap.

Link