Skip to main content

Command documentation sourced from the linux-command project This comprehensive command reference is part of the linux-command documentation project.

fping - Advanced Ping Utility for Network Scanning

The fping command is a high-performance ping utility that can ping multiple hosts simultaneously and much more efficiently than the standard ping command. Unlike traditional ping tools that ping one host at a time, fping can send ICMP echo requests to multiple hosts in parallel, making it ideal for network discovery, monitoring, and troubleshooting. It supports various output formats, timing controls, and advanced features like host generation from CIDR notation and statistical reporting.

Basic Syntax

fping [OPTIONS] [HOSTS...]

Common Options

Basic Ping Options

  • -a - Show only alive hosts
  • -u - Show only unreachable hosts
  • -c COUNT - Send COUNT packets to each target
  • -i INTERVAL - Set interval between packets (in milliseconds)
  • -t TIMEOUT - Set timeout for replies (in milliseconds)
  • -r RETRY - Set retry count
  • -s - Print summary statistics
  • -v - Verbose output

Target Selection

  • -g - Generate target hosts from CIDR notation
  • -f FILE - Read hosts from file
  • -d - Use DNS name resolution

Output Control

  • -q - Quiet mode (minimal output)
  • -n - Show hostnames in output
  • -D - Print timestamp before each line
  • -e - Show elapsed time on return packets

Advanced Options

  • -B BACKOFF - Set exponential backoff factor
  • -C COUNT - Similar to -c but returns better statistics
  • -O TOFFSET - Set time offset for responses
  • -P PERIOD - Send packets at specified intervals
  • -R - Randomize packet intervals
  • -S SOURCE - Set source IP address

Usage Examples

Basic Ping Operations

Single Host Pinging

# Basic ping to a single host
fping google.com

# Ping with specific count
fping -c 4 google.com

# Ping with custom timeout
fping -t 2000 google.com

# Verbose ping output
fping -v google.com

# Quiet mode ping
fping -q google.com

Multiple Hosts Pinging

# Ping multiple hosts at once
fping google.com facebook.com twitter.com

# Show only alive hosts
fping -a google.com facebook.com invalid-host.local

# Show only unreachable hosts
fping -u google.com invalid-host.local facebook.com

# Ping hosts from file
fping -f hostlist.txt

# Generate targets from CIDR notation
fping -g 192.168.1.0/24

# Ping a range of IPs
fping -g 192.168.1.1 192.168.1.50

Network Discovery and Scanning

Subnet Scanning

# Scan entire subnet
fping -a -g 192.168.1.0/24

# Scan subnet with custom timing
fping -a -g 10.0.0.0/24 -i 10 -t 500

# Scan multiple subnets
fping -a -g 192.168.1.0/24 -g 192.168.2.0/24

# Quick scan with minimal timeout
fping -a -g 172.16.0.0/16 -t 100 -i 5

Host Discovery

# Discover alive hosts in network
fping -a -q -g 192.168.1.0/24

# Count alive hosts
fping -a -g 192.168.1.0/24 | wc -l

# Save alive hosts to file
fping -a -g 192.168.1.0/24 > alive_hosts.txt

# Discover hosts with timestamp
fping -a -D -g 192.168.1.0/24

Performance and Timing

High-Speed Pinging

# Fast ping with short intervals
fping -c 10 -i 1 google.com

# Very fast ping (requires root)
fping -c 100 -i 0.1 google.com

# Ping with custom retry
fping -c 5 -r 3 google.com

# Ping with exponential backoff
fping -c 10 -B 2 google.com

Statistical Analysis

# Ping with detailed statistics
fping -c 20 -s google.com

# Better statistics format
fping -C 10 google.com

# Random packet intervals
fping -c 20 -R google.com

# Periodic pinging
fping -c 60 -P 1 google.com

Advanced Network Monitoring

Continuous Monitoring

# Continuous monitoring with timestamp
fping -D -s -c 0 google.com

# Monitor multiple hosts continuously
fping -D -s -c 0 -f critical_hosts.txt

# Monitor with custom source IP
fping -s -S 192.168.1.100 -g 192.168.1.0/24

# Monitor with period control
fping -c 0 -P 5 google.com

Network Latency Testing

# Test latency to multiple servers
fping -c 10 -s dns1.google.com dns2.google.com 8.8.8.8 1.1.1.1

# Compare response times
fping -c 5 -C server1.example.com server2.example.com

# Test network path reliability
fping -c 100 -s gateway.local router.local internet-host.com

Practical Examples

System Administration

Network Health Monitoring

# Check all critical servers
fping -a -q -f /etc/hosts | grep -v "is alive" || echo "All hosts reachable"

# Monitor network segment health
fping -a -g 10.0.0.0/24 -t 1000 -i 50 > network_scan_$(date +%Y%m%d).log

# Generate network health report
fping -c 10 -s $(cat critical_servers.txt) > health_report_$(date +%Y%m%d).txt

# Check gateway connectivity
fping -c 3 -q $(ip route | grep default | awk '{print $3}') && echo "Gateway OK"

DHCP Range Scanning

# Scan DHCP range for active hosts
fping -a -g 192.168.1.100 192.168.1.200

# Find unused IP addresses
fping -a -g 192.168.1.1 192.168.1.254 | awk '{print $1}' > used_ips.txt
comm -23 <(seq 192.168.1.1 192.168.1.254 | sort) <(sort used_ips.txt) > available_ips.txt

# Monitor new devices joining network
watch -n 60 "fping -a -g 192.168.1.0/24 | wc -l"

Security and Auditing

Network Security Scanning

# Quick security scan of network
fping -a -s -g 192.168.1.0/24 > security_scan.txt

# Detect rogue devices
fping -a -g 10.0.0.0/24 | sort > current_hosts.txt
diff known_hosts.txt current_hosts.txt

# Monitor for new hosts
while true; do
fping -a -g 192.168.1.0/24 > current_scan.txt
if diff last_scan.txt current_scan.txt; then
echo "No changes detected"
else
echo "Network topology changed!"
diff last_scan.txt current_scan.txt
fi
cp current_scan.txt last_scan.txt
sleep 300
done

Firewall Testing

# Test firewall connectivity
fping -c 5 -s internal-server.example.com external-server.example.com

# Test specific ports with ICMP
fping -c 3 -q -t 2000 firewall.example.com

# Monitor network availability
fping -a -q -c 0 $(cat monitoring_hosts.txt) | while read line; do
echo "$(date): $line"
done

Development and Testing

Load Balancer Testing

# Test multiple web servers
fping -c 20 -s web1.example.com web2.example.com web3.example.com

# Verify load balancer health
for server in web1 web2 web3; do
echo "Testing $server.example.com"
fping -c 10 -s $server.example.com
done

# Compare server response times
fping -C 5 -s $(cat web_servers.txt)

Application Network Testing

# Test application server connectivity
fping -c 10 -s $(cat app_servers.txt) > app_connectivity_$(date +%Y%m%d).log

# Monitor database server connectivity
fping -c 0 -P 1 -q $(cat db_servers.txt) | while read line; do
host=$(echo $line | awk '{print $1}')
status=$(echo $line | awk '{print $3}')
echo "$(date): $host - $status" >> db_connectivity.log
done

# Network latency testing for applications
fping -C 100 -s api-server.example.com > api_latency_test.txt

Advanced Usage

Script Integration

Network Monitoring Script

#!/bin/bash
# Comprehensive network monitoring with fping

HOSTS_FILE="/etc/network_hosts"
LOG_FILE="/var/log/network_monitor.log"
ALERT_THRESHOLD=3

# Function to check hosts
check_hosts() {
timestamp=$(date "+%Y-%m-%d %H:%M:%S")
failed_hosts=""

while read host; do
if ! fping -c 3 -q "$host" 2>/dev/null; then
failed_hosts="$failed_hosts $host"
echo "$timestamp - FAILED: $host" >> "$LOG_FILE"
else
echo "$timestamp - OK: $host" >> "$LOG_FILE"
fi
done < "$HOSTS_FILE"

# Send alert if too many failures
failed_count=$(echo "$failed_hosts" | wc -w)
if [ "$failed_count" -gt "$ALERT_THRESHOLD" ]; then
echo "ALERT: $failed_count hosts failed: $failed_hosts" | \
mail -s "Network Monitor Alert" admin@example.com
fi
}

# Run the check
check_hosts

Network Discovery Script

#!/bin/bash
# Network discovery and mapping

NETWORKS="192.168.1.0/24 10.0.0.0/24"
OUTPUT_DIR="/tmp/network_discovery"
DATE=$(date +%Y%m%d_%H%M%S)

mkdir -p "$OUTPUT_DIR"

for network in $NETWORKS; do
echo "Discovering $network..."
fping -a -g "$network" -t 500 -i 10 > "$OUTPUT_DIR/alive_${network//\//_}_${DATE}.txt"
echo "Found $(wc -l < "$OUTPUT_DIR/alive_${network//\//_}_${DATE}.txt") alive hosts in $network"
done

# Generate consolidated report
echo "Network Discovery Report - $DATE" > "$OUTPUT_DIR/report_${DATE}.txt"
echo "================================" >> "$OUTPUT_DIR/report_${DATE}.txt"
for network in $NETWORKS; do
echo -e "\n$network:" >> "$OUTPUT_DIR/report_${DATE}.txt"
cat "$OUTPUT_DIR/alive_${network//\//_}_${DATE}.txt" >> "$OUTPUT_DIR/report_${DATE}.txt"
done

Performance Optimization

Parallel Processing

# Parallel ping with xargs
echo -e "192.168.1.1\n192.168.1.2\n192.168.1.3" | xargs -P 10 -I {} fping -c 3 {}

# Fast network scan with parallel processing
seq 1 254 | xargs -P 50 -I {} fping -q -t 100 192.168.1.{}

# Parallel host verification from multiple sources
(cat hosts1.txt; cat hosts2.txt; cat hosts3.txt) | sort -u | \
xargs -P 20 -I {} fping -c 1 -q {}

Memory and Resource Optimization

# Low resource usage scanning
fping -a -g 192.168.0.0/16 -t 100 -i 1 -r 1

# Batch processing large networks
for i in {0..15}; do
subnet="10.0.$i.0/24"
fping -a -g "$subnet" -t 200 -i 5 &
done
wait

# Incremental scanning
fping -a -g 192.168.1.0/24 | while read host; do
echo "Processing $host..."
# Additional processing for each alive host
done

Troubleshooting

Common Issues

Permission and Access Issues

# Permission denied for low intervals
# Solution: Use sudo or increase interval
sudo fping -c 100 -i 0.1 target.com
fping -c 100 -i 10 target.com # Non-privileged users need 10ms+ interval

# Cannot bind to socket
# Solution: Check if another fping instance is running
ps aux | grep fping
sudo pkill fping

# Source address not available
# Solution: Use correct source IP or check network interfaces
ip addr show
fping -S 192.168.1.100 target.com

Network and DNS Issues

# DNS resolution failures
# Solution: Use IP addresses directly or check DNS
fping -n 8.8.8.8
nslookup google.com

# Host unreachable but ping works
# Solution: Check routing and firewall rules
ip route show
iptables -L

# High packet loss
# Solution: Increase timeout or check network quality
fping -t 5000 -c 10 target.com
fping -r 5 -c 10 target.com

Performance Issues

# Slow scanning
# Solution: Optimize timing parameters
fping -a -g 192.168.1.0/24 -t 200 -i 5 -r 1

# Too many concurrent processes
# Solution: Limit parallel operations
fping -a -g 192.168.1.0/24 | xargs -P 5 -I {} echo {}

# Memory issues with large scans
# Solution: Process in batches
for octet in {0..15}; do
fping -a -g 192.168.$octet.0/24
done

Debugging Techniques

Verbose and Debug Output

# Enable verbose output
fping -v -c 5 target.com

# Show timing information
fping -D -c 5 target.com

# Debug network issues
fping -c 10 -s target.com 2>&1 | tee debug_output.txt

Network Diagnostics

# Test with different packet sizes (if supported)
fping -c 5 -s target.com

# Test path MTU discovery
for size in 1000 1200 1400 1472; do
echo "Testing size $size"
fping -c 3 -t 1000 target.com
done

# Monitor network behavior over time
fping -c 0 -P 60 -s target.com &
PID=$!
sleep 3600
kill $PID
  • ping - Standard ICMP echo utility
  • ping6 - IPv6 ping utility
  • mtr - Network diagnostic tool combining ping and traceroute
  • traceroute - Trace network path to host
  • nmap - Network exploration and security auditing tool
  • netstat - Network connections monitoring
  • ss - Socket statistics utility
  • arping - Send ARP REQUEST to a host
  • hping3 - Network packet generator and analyzer
  • tcpdump - Network packet analyzer

Best Practices

  1. Use appropriate timing intervals - Non-privileged users need 10ms+ intervals
  2. Set reasonable timeouts - Avoid long waits on unresponsive hosts
  3. Use CIDR notation for efficient network scanning
  4. Combine with other tools like nmap for comprehensive network analysis
  5. Use quiet mode (-q) in scripts to reduce output noise
  6. Monitor system resources during large-scale scans
  7. Use timestamping (-D) for logging and analysis
  8. Implement error handling in automated scripts
  9. Respect network policies and avoid overwhelming networks
  10. Document scan purposes and obtain proper authorization

Performance Tips

  1. Parallel processing dramatically speeds up large scans
  2. Batch processing of large networks prevents resource exhaustion
  3. Short timeouts (100-500ms) are usually sufficient for LAN scans
  4. Minimal retry counts (1-2) for quick discovery scans
  5. Use source IP selection (-S) for testing specific network paths
  6. Combine with grep and other text tools for output analysis
  7. Store results in files for historical comparison
  8. Use appropriate intervals based on network conditions
  9. Limit concurrent scans on shared networks
  10. Monitor progress during long-running scans

The fping command is an essential tool for network administrators, security professionals, and system administrators who need efficient network discovery and monitoring capabilities. Its ability to ping multiple hosts simultaneously makes it far more efficient than traditional ping utilities for large-scale network operations, while its flexible output formats and timing controls make it suitable for everything from quick host discovery to detailed network performance analysis.