Fping – Ubuntu 上用于并行 Ping 主机的命令行工具


Fping 是一个向网络主机发送 ICMP 回显探测的程序,它类似于 ping,允许用户检查远程主机是否在线。使用 Fping 命令,我们可以同时检查多个主机。本文介绍了“如何安装 Fping 命令以及 Fping 命令的用法”。

安装 Fping 命令

要安装 Fping 命令,请使用以下命令:

$ sudo apt-get install fping

示例输出应如下所示:

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
   gtk2-engines-pixbuf libbs2b0 libopusfile0 libpyside1.2 libqmmp-misc
   libqmmpui0 libshiboken1.2 libsidplayfp libtidy-0.99-0 linux-headers-4.2.0-27
   linux-headers-4.2.0-27-generic linux-image-4.2.0-27-generic
   linux-image-extra-4.2.0-27-generic linux-signed-image-4.2.0-27-generic
   php7.0-opcache python-beautifulsoup python-feedparser python-html2text
   python-magic python-oauth2 python-pyside.qtcore python-pyside.qtgui
   python-pyside.qtnetwork python-pyside.qtwebkit python-pysqlite2 python-regex
   python-sqlalchemy python-sqlalchemy-ext python-support python-unity-singlet
   python-utidylib
Use 'apt-get autoremove' to remove them.
The following NEW packages will be installed:
   fping
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 30.7 kB of archives.
.........................................................

Fping 命令的用法

要运行 Fping,请使用以下命令:

$ fping tutorialspoint.com

示例输出应如下所示:

tutorialspoint.com is alive

要测试多个站点,请使用以下命令:

$ fping www.tutorialspoint.com www.google.com

示例输出应如下所示:

www.tutorialspoint.com is alive
www.google.com is alive

如果主机列表存储在一个文件中,请使用以下命令:

$ fping < hosts.txt

示例输出应如下所示:

www.tutorialspoint.com is alive
www.google.com is alive

要获取有关fping的更多信息,请使用以下命令:

$ fping -help

示例输出应如下所示:

Usage: fping [options] [targets...]
-a    show targets that are alive
-A    show targets by address
-b n  amount of ping data to send, in bytes (default 56)
-B f  set exponential backoff factor to f
-c n  count of pings to send to each target (default 1)
-C n  same as -c, report results in verbose format
-D    print timestamp before each output line
-e    show elapsed time on return packets
-f    file read list of targets from a file ( - means stdin) (only if no -g specified)
-g    generate target list (only if no -f specified)
         (specify the start and end IP in the target list, or supply a IP netmask)
         (ex. fping -g 192.168.1.0 192.168.1.255 or fping -g 192.168.1.0/24)
-H n  Set the IP TTL value (Time To Live hops)
-i n  interval between sending ping packets (in millisec) (default 25)
-l    loop sending pings forever
-m    ping multiple interfaces on target host
-n    show targets by name (-d is equivalent)
-p n  interval between ping packets to one target (in millisec)
         (in looping and counting modes, default 1000)
-q    quiet (don't show per-target/per-ping results)
-Q n  same as -q, but show summary every n seconds
-r n  number of retries (default 3)
-s    print final stats
-I    if bind to a particular interface
-S    addr set source address
-t n  individual target initial timeout (in millisec) (default 500)
-T n  ignored (for compatibility with fping 2.4)
-u    show targets that are unreachable
-O n  set the type of service (tos) flag on the ICMP packets
-v    show version
targets list of targets to check (if no -f specified)

恭喜!现在您知道了“如何在 Linux 上安装和使用 Fping 工具”。我们将在下一篇文章中学习更多关于这类 Linux 命令的内容。继续关注!

更新于:2020年1月20日

971 次浏览

开启您的职业生涯

完成课程获得认证

开始学习
广告
© . All rights reserved.