Ping

Ping

One-liner: A network utility that sends ICMP Echo requests to test connectivity and determine if a remote host is online.

🎯 What Is It?

Ping is a fundamental network diagnostic tool that sends ICMP Echo Request packets (Type 8) to a target and waits for Echo Reply packets (Type 0). It's used to verify that a host is reachable and measure round-trip latency.

The name comes from sonarβ€”like pinging a submarine to detect its location.

πŸ€” Why It Matters

πŸ”¬ How It Works

Core Principles

  1. Sends ICMP Echo Request (Type 8, Code 0) to target
  2. Target responds with ICMP Echo Reply (Type 0, Code 0)
  3. Measures time between request and reply (RTT)
  4. Reports statistics: packets sent, received, lost, and timing

Technical Deep-Dive

# Linux: Send 5 ping packets
ping -c 5 10.10.10.1

# Windows: Send 5 ping packets
ping -n 5 10.10.10.1

# Linux: Set custom packet size (data portion)
ping -s 1000 -c 3 10.10.10.1

# Linux: Flood ping (requires root)
sudo ping -f 10.10.10.1

ICMP Header Structure

Field Size Description
Type 1 byte 8 for Echo Request, 0 for Echo Reply
Code 1 byte Always 0 for ping
Checksum 2 bytes Error-checking
Identifier 2 bytes Match requests to replies
Sequence 2 bytes Track packet order
Total ICMP Header 8 bytes

πŸ›‘οΈ Detection & Prevention

How to Detect

How to Prevent / Mitigate

πŸ“Š Command Options

Option (Linux) Option (Windows) Description
-c <count> -n <count> Number of packets to send
-s <size> -l <size> Payload size in bytes
-i <interval> -w <timeout> Interval/timeout settings
-t <ttl> -i <ttl> Set TTL (Time To Live)
-W <timeout> -w <timeout> Wait timeout for reply

🎀 Interview Angles

Common Questions

STAR Story

Situation: During a pentest, initial nmap scans showed all hosts as down.
Task: Determine if hosts were actually offline or blocking ICMP.
Action: Used nmap with -Pn flag to skip host discovery and ran TCP SYN scans directly. Also tried ARP ping for local subnet.
Result: Discovered 12 live hosts with open services that were blocking ICMPβ€”classic firewall evasion scenario.

βœ… Best Practices

❌ Common Misconceptions

πŸ“š References