Ping: Complete Guide to Network Connectivity Testing and Host Availability Using Kali Linux

Ping: Complete Guide to Network Connectivity Testing and Host Availability Using Kali Linux

1. Tool Introduction

ping is the most fundamental and universally recognized network diagnostic utility, first written by Mike Muuss in 1983. It sends ICMP Echo Request packets to a target host and listens for ICMP Echo Reply packets, allowing a user to verify that a host is reachable across an IP network and to measure round-trip latency and packet loss. Despite its simplicity, ping remains an indispensable first step in nearly every network troubleshooting and reconnaissance workflow, and is present on virtually every operating system, including Kali Linux by default (via the iputils-ping package).

2. Installation

ping ships pre-installed on Kali Linux as part of iputils-ping. If missing:

sudo apt update
sudo apt install iputils-ping -y

Verify:

ping -V

Expected output:

ping from iputils 20221126

3. Syntax

ping [OPTIONS] <destination>

4. Command-Line Options (Full Reference)

5. Basic Usage

ping -c 4 8.8.8.8

Expected output:

PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=117 time=12.4 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=117 time=12.1 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=117 time=12.6 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=117 time=12.2 ms

--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 12.100/12.325/12.600/0.190 ms

6. Practical Examples

Example 1 — Basic reachability check with a fixed count

ping -c 4 192.168.1.1
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.512 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.489 ms
4 packets transmitted, 4 received, 0% packet loss

Example 2 — Adjust interval between packets

ping -i 2 -c 3 8.8.8.8
64 bytes from 8.8.8.8: icmp_seq=1 ttl=117 time=12.3 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=117 time=12.1 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=117 time=12.4 ms

Example 3 — Specify source interface

ping -I eth0 -c 3 192.168.1.10
64 bytes from 192.168.1.10: icmp_seq=1 ttl=64 time=0.601 ms

Example 4 — Set custom packet size

ping -s 1000 -c 3 192.168.1.10
1008 bytes from 192.168.1.10: icmp_seq=1 ttl=64 time=0.789 ms

Example 5 — Quiet mode with a total deadline

ping -q -w 5 192.168.1.10
PING 192.168.1.10 (192.168.1.10) 56(84) bytes of data.

--- 192.168.1.10 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4004ms
rtt min/avg/max/mdev = 0.480/0.560/0.650/0.05 ms

Example 6 — Numeric output only (skip reverse DNS)

ping -n -c 3 8.8.8.8
64 bytes from 8.8.8.8: icmp_seq=1 ttl=117 time=12.2 ms

Example 7 — Set custom TTL to test hop distance

ping -t 1 -c 1 8.8.8.8
From 192.168.1.1: icmp_seq=1 Time to live exceeded

Example 8 — Timestamped output

ping -D -c 3 192.168.1.10
[1752912345.123456] 64 bytes from 192.168.1.10: icmp_seq=1 ttl=64 time=0.512 ms

Example 9 — Flood ping (lab/authorized testing only, requires root)

sudo ping -f -c 1000 192.168.1.10
.....
--- 192.168.1.10 ping statistics ---
1000 packets transmitted, 1000 received, 0% packet loss

Example 10 — Set response wait timeout

ping -c 3 -W 1 192.168.1.99
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
--- 192.168.1.99 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss

7. Common Use Cases

8. Automation with Bash

#!/bin/bash
# ping_check.sh - check reachability of a list of hosts
HOSTS_FILE="hosts.txt"
OUT="ping_results.csv"
echo "host,status" > "$OUT"

while read -r host; do
    if ping -c 2 -W 1 -q "$host" > /dev/null 2>&1; then
        echo "$host,UP" >> "$OUT"
    else
        echo "$host,DOWN" >> "$OUT"
    fi
done < "$HOSTS_FILE"

echo "[+] Results saved to $OUT"
column -s, -t "$OUT"

9. Tips and Best Practices

10. Troubleshooting

11. References

Exit mobile version