网站搜索

Fping - 适用于 Linux 的高性能 Ping 工具


fping 是一个小型命令行工具,用于向网络主机发送 ICMPInternet 控制消息协议)回显请求,类似于 ping,但性能更高ping 多个主机时执行。 fping 与 ping 完全不同,您可以在命令行上定义任意数量的主机,或者指定一个包含要 ping 的 IP 地址或主机列表的文件。

另请阅读:Linux 系统管理员网络管理、故障排除和调试指南

例如,使用fping,我们可以指定完整的网络范围(192.168.0.1/24)。它将向主机发送 Fping 请求,并以循环方式移动到另一个目标主机。与 ping 不同,Fping 基本上用于脚本编写。

如何在Linux系统中安装Fping

在大多数 Linux 发行版中,可以使用包管理工具从默认包存储库安装包 fping,如图所示。

sudo apt install fping  [On Debian/Ubuntu]
sudo yum install fping  [On CentOS/RHEL]
sudo dnf install fping  [On Fedora 22+]
sudo pacman -S fping    [On Arch Linux]

或者,您可以使用以下命令从源包安装最新版本的 fping (4.0)。

wget https://fping.org/dist/fping-4.0.tar.gz
tar -xvf fping-4.0.tar.gz
cd fping-4.0/
./configure
make && make install

让我们看看一些 Fping 命令及其示例。

1. Fping 多个IP地址

以下命令将同时 fping 多个 IP 地址,并将状态显示为活动或无法访问。

fping 50.116.66.139 173.194.35.35 98.139.183.24

50.116.66.139 is alive
173.194.35.35 is unreachable
98.139.183.24 is unreachable

2. Fping IP 地址范围

以下命令将 fping 指定范围的 IP 地址。通过以下输出,我们向 IP 地址范围发送回显请求并根据需要获得回复。退出后还会显示累积结果。

fping -s -g 192.168.0.1 192.168.0.9

192.168.0.1 is alive
192.168.0.2 is alive
ICMP Host Unreachable from 192.168.0.2 for ICMP Echo sent to 192.168.0.3
ICMP Host Unreachable from 192.168.0.2 for ICMP Echo sent to 192.168.0.3
ICMP Host Unreachable from 192.168.0.2 for ICMP Echo sent to 192.168.0.3
ICMP Host Unreachable from 192.168.0.2 for ICMP Echo sent to 192.168.0.4
192.168.0.3 is unreachable
192.168.0.4 is unreachable

8      9 targets
       2 alive
       2 unreachable
       0 unknown addresses

       4 timeouts (waiting for response)
       9 ICMP Echos sent
       2 ICMP Echo Replies received
      2 other ICMP received

 0.10 ms (min round trip time)
 0.21 ms (avg round trip time)
 0.32 ms (max round trip time)
        4.295 sec (elapsed real time)

3. Fping完整网络,具有不同的选项

使用上述命令,它将 ping 完整网络并重复一次 (-r 1)。抱歉,无法显示命令的输出,因为它没有时间向上滚动我的屏幕。

fping -g -r 1 192.168.0.0/24

4. 从文件中读取目标列表

我们创建了一个名为 fping.txt 的文件,其中包含 fping 的 IP 地址(173.194.35.3598.139.183.24)。

fping < fping.txt

173.194.35.35 is alive
98.139.183.24 is alive

5. 显示Fping版本

执行命令查看Fping版本。

fping -v

fping: Version 4.0
fping: comments to [email 

如果想要了解有关 Fping 命令选项的更多信息,请查看手册页。还要求在您的环境中尝试 Fping 命令,并通过下面的评论框与我们分享您的经验。