Linux command
fping 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Ping multiple hosts
fping [host1] [host2] [host3]
Ping hosts from a file
fping -f [path/to/hosts.txt]
Ping a range of IP addresses
fping -g [192.168.1.1] [192.168.1.254]
Ping a CIDR range
fping -g [192.168.1.0/24]
Show only alive hosts
fping -a [host1] [host2]
Show only unreachable hosts
fping -u [host1] [host2]
Ping with statistics
fping -s [host1] [host2]
Continuous ping
fping -l -p [1000] [host]
说明
fping is designed for scripting and monitoring, offering significant advantages over the standard ping command for checking multiple hosts. It can ping many hosts in parallel and report results in formats suitable for parsing. Unlike ping which waits for each host to respond before continuing, fping sends probes in a round-robin fashion to all targets, then waits for responses. This parallelism makes it vastly faster when checking many hosts. The tool is commonly used in network monitoring scripts, host discovery, and availability checking. The -g option for generating IP ranges enables quick subnet scans. Exit codes indicate overall reachability status, useful in scripts. Output modes range from verbose per-ping information to quiet mode showing only summaries. The alive-only (-a) and unreachable-only (-u) modes simplify parsing when you only need specific results. fping can read targets from files or stdin, enabling integration with other tools. For continuous monitoring, loop mode (-l) with custom intervals provides ongoing status updates.
参数
- -a
- Show only alive (reachable) hosts.
- -u
- Show only unreachable hosts.
- -g _addr/mask_ or _start end_
- Generate target list from CIDR or range.
- -f _file_
- Read targets from file (- for stdin).
- -c _count_
- Number of pings to send per target.
- -l
- Loop: keep pinging indefinitely.
- -p _period_
- Interval between pings to same target (ms).
- -i _interval_
- Interval between pings to different targets (ms).
- -t _timeout_
- Individual ping timeout in milliseconds.
- -r _retry_
- Number of retries for unreachable hosts.
- -s
- Print cumulative statistics at end.
- -q
- Quiet: only show summary.
- -e
- Show elapsed time for replies.
- -A
- Show targets by IP address.
- -D
- Show timestamps before each line.
- -S _source_
- Set source address.
- -b _size_
- Ping packet size in bytes.
FAQ
What is the fping command used for?
fping is designed for scripting and monitoring, offering significant advantages over the standard ping command for checking multiple hosts. It can ping many hosts in parallel and report results in formats suitable for parsing. Unlike ping which waits for each host to respond before continuing, fping sends probes in a round-robin fashion to all targets, then waits for responses. This parallelism makes it vastly faster when checking many hosts. The tool is commonly used in network monitoring scripts, host discovery, and availability checking. The -g option for generating IP ranges enables quick subnet scans. Exit codes indicate overall reachability status, useful in scripts. Output modes range from verbose per-ping information to quiet mode showing only summaries. The alive-only (-a) and unreachable-only (-u) modes simplify parsing when you only need specific results. fping can read targets from files or stdin, enabling integration with other tools. For continuous monitoring, loop mode (-l) with custom intervals provides ongoing status updates.
How do I run a basic fping example?
Run `fping [host1] [host2] [host3]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -a do in fping?
Show only alive (reachable) hosts.