Skip to main content

ping Cheatsheet

By Dejan Panovski Updated on Download PDF

Quick reference for testing network reachability and latency with ping in Linux

The `ping` command tests whether a host is reachable and shows round-trip latency. This cheatsheet covers common IPv4 and IPv6 checks, count and interval options, packet sizing, and practical troubleshooting patterns.

Basic Syntax

Core ping command forms.

CommandDescription
ping hostContinuously ping a host
ping -c 4 hostSend 4 echo requests, then stop
ping -i 2 hostWait 2 seconds between packets
ping -w 10 hostStop after 10 seconds
ping --helpShow available options

Common Reachability Checks

Quick tests for DNS names and IP addresses.

CommandDescription
ping google.comTest DNS resolution and connectivity
ping 8.8.8.8Test reachability to a public IPv4 address
ping localhostVerify local TCP/IP stack
`ping $(hostname -Iawk ‘{print $1}’)`
ping router.localTest a local network device by hostname

Count and Timing

Control how many packets are sent and how long ping runs.

CommandDescription
ping -c 3 hostSend exactly 3 packets
ping -c 5 -i 0.5 hostSend 5 packets at 0.5-second intervals
ping -w 5 hostStop after 5 seconds total
ping -W 2 hostWait up to 2 seconds for each reply
ping -c 10 -q hostShow summary only after 10 packets

IPv4 and IPv6

Force the address family when needed.

CommandDescription
ping -4 hostUse IPv4 only
ping -6 hostUse IPv6 only
ping6 hostIPv6 ping on systems that provide ping6
ping -c 4 -4 example.comCheck IPv4 replies for a dual-stack host
ping -c 4 -6 example.comCheck IPv6 replies for a dual-stack host

Packet Size and Interface

Adjust packet payload and source interface.

CommandDescription
ping -s 1400 hostSend larger packets with 1400-byte payload
ping -s 56 hostUse the default payload size explicitly
ping -I eth0 hostSend packets from a specific interface
ping -I 192.168.1.10 hostUse a specific source address
ping -D hostPrint timestamps before each reply

Troubleshooting

Quick checks for common ping issues.

IssueCheck
Name or service not knownDNS failed; test with an IP address directly
Destination Host UnreachableCheck routing, gateway, and local network link
100% packet lossThe host may be down, blocked by a firewall, or not routing replies
ping: socket: Operation not permittedUse sudo or verify capabilities on systems with restricted raw sockets
IPv6 ping fails onlyConfirm the host has AAAA records and IPv6 connectivity

Use these guides for broader network troubleshooting workflows.

GuideDescription
ping Command in LinuxFull ping guide with detailed examples
IP command cheatsheetInspect interfaces, addresses, and routes
ss Command in LinuxInspect sockets and active network connections
traceroute Command in LinuxTrace the route packets take to a host
SSH cheatsheetQuick reference for remote connectivity commands