ping ‐ #networking #troubleshooting - five4nets/Linux-Knowledgebase GitHub Wiki

Sure! Here's a comprehensive tutorial in Markdown format for using the ping command in Linux:

🛰️ Linux ping Command Tutorial

The ping command is a simple yet powerful network diagnostic tool used to test the reachability of a host and measure round-trip time for messages sent from your machine to a destination.


📌 What Is ping?

ping (Packet Internet Groper) sends ICMP ECHO_REQUEST packets to a specified host and waits for ICMP ECHO_REPLY responses. It's commonly used to:

  • Check if a host is reachable.
  • Measure latency (round-trip time).
  • Diagnose network issues.

🧰 Basic Syntax

ping [options] destination
  • destination: IP address or hostname (e.g., google.com)
  • options: Optional flags to modify behavior

🧪 Common Examples

1. Ping a Website

ping google.com

This sends continuous ping requests to google.com until you stop it with Ctrl + C.

2. Limit the Number of Pings

ping -c 4 example.com

Sends exactly 4 packets and then stops.

3. Ping an IP Address

ping 8.8.8.8

Useful for checking if DNS is the issue.

4. Set Interval Between Pings

ping -i 2 example.com

Sends a ping every 2 seconds.

5. Set Timeout for Each Ping

ping -W 3 example.com

Waits 3 seconds for a reply before considering it a failure.

6. Ping with IPv6

ping6 ipv6.google.com

⚙️ Useful Options

Option Description
-c Number of packets to send
-i Interval between packets
-W Timeout for each reply
-s Packet size in bytes
-q Quiet output (summary only)
-v Verbose output
-4 Force IPv4
-6 Force IPv6

🧠 Interpreting Output

Example output:

64 bytes from 8.8.8.8: icmp_seq=1 ttl=117 time=14.2 ms
  • icmp_seq: Sequence number of the packet
  • ttl: Time to live (max hops)
  • time: Round-trip time in milliseconds

📚 References


🧭 Pro Tip

Use man ping in your terminal to explore all available options and learn more about how ping works under the hood.


Happy pinging! 🧑‍💻


Let me know if you'd like this turned into a downloadable `.md` file or expanded with troubleshooting tips!