🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

ping Command

Beginner Networking man(1)

Send ICMP echo requests to test network connectivity

👁 10 views 📅 Updated: Mar 15, 2026
SYNTAX
ping [OPTION]... DESTINATION

What Does ping Do?

The ping command tests network connectivity by sending ICMP echo requests to a host and measuring response times. It is the first tool used when diagnosing network problems — if ping works, basic network connectivity is established.

ping measures round-trip time (RTT), packet loss, and jitter. It sends packets at regular intervals (1 second by default) and reports statistics including minimum, average, maximum, and standard deviation of response times.

Ping is used for verifying host availability, measuring network latency, troubleshooting DNS resolution, detecting packet loss, and monitoring network quality. It works with both IP addresses and hostnames.

Options & Flags

OptionDescriptionExample
-c Send N packets then stop ping -c 5 google.com
-i Set interval between packets (seconds) ping -i 0.5 192.168.1.1
-W Set timeout for each reply (seconds) ping -W 2 server.local
-s Set packet size in bytes ping -s 1472 gateway
-f Flood ping (requires root) sudo ping -f -c 1000 192.168.1.1
-q Quiet — show only summary statistics ping -q -c 10 8.8.8.8
-4/-6 Force IPv4 or IPv6 ping -4 google.com
-t Set TTL (Time To Live) ping -t 5 192.168.1.1

Practical Examples

#1 Basic connectivity test

Sends 4 packets to Google and shows round-trip times.
$ ping -c 4 google.com
Output: PING google.com (142.250.74.14): 64 bytes, icmp_seq=0 ttl=117 time=12.3 ms --- google.com ping statistics --- 4 packets transmitted, 4 received, 0% packet loss rtt min/avg/max = 11.2/12.5/14.1 ms

#2 Test local network

Pings the default gateway to verify local network works.
$ ping -c 3 192.168.1.1

#3 Quick host check

Single packet with 2-second timeout — fast alive/dead check for scripts.
$ ping -c 1 -W 2 server.example.com

#4 Continuous monitoring

Runs continuously until Ctrl+C. Shows real-time latency monitoring.
$ ping google.com

#5 Test with specific packet size

Tests with large packets to verify MTU and detect fragmentation issues.
$ ping -c 3 -s 1472 192.168.1.1

#6 Summary only

Sends 100 packets but only shows the summary statistics.
$ ping -q -c 100 8.8.8.8

Tips & Best Practices

Script-friendly check: Use ping -c 1 -W 1 host > /dev/null 2>&1 && echo "UP" || echo "DOWN" for quick host availability checking in scripts.
Ping blocked by firewalls: Many servers block ICMP ping. No response does not always mean the host is down — the firewall may be blocking ICMP.
Flood ping caution: ping -f sends packets as fast as possible. Only use on networks you own. It can saturate network links and trigger security alerts.

Frequently Asked Questions

What does "Request timeout" mean?
It means no reply was received within the timeout period. The host may be down, unreachable, or blocking ICMP. Check firewall rules and routing.
What is a good ping time?
Under 1ms for local network, 10-30ms for regional, 50-100ms for continental, 100-300ms for intercontinental. Anything under 50ms is excellent for most uses.
How do I ping continuously?
On Linux, ping runs continuously by default. Press Ctrl+C to stop and see statistics. Use -c N to limit to N packets.

Master Linux with Professional eBooks

Curated IT eBooks covering Linux, DevOps, Cloud, and more

Browse Books →