你好,游客 登录 注册 搜索
阅读内容

网络小工具 fping

运行环境:
授权方式:BSD
软件大小:M
下载量:
更新日期:2014-05-05
来源地址:
联系作者:Linux

fping 是一个类似 ping 的程序,与 ping 不同的是你可以同时指定多个要 ping 的目标。fping 发送完 ping 包后不等待回应,而是继续下一个目标。

fping命令可以接受一个机器列表,以round-robin方式ping,效率很高。

官方介绍:

fping is a ping(1) like program which uses the Internet Control Message Protocol (ICMP) echo request to determine if a host is up. fping is different from ping in that you can specify any number of hosts on the command line, or specify a file containing the lists of hosts to ping. Instead of trying one host until it timeouts or replies, fping will send out a ping packet and move on to the next host in a round-robin fashion. If a host replies, it is noted and removed from the list of hosts to check. If a host does not respond within a certain time limit and/or retry limit it will be considered unreachable.

Unlike ping, fping is meant to be used in scripts and its output is easy to parse.

您可能直接使用apt-get安装,也可能在官网下载源码编译安装。

-a Show systems that are alive.

-A Display targets by address rather than DNS name.

-bn Number of bytes of ping data to send. The minimum size (normally 12) allows room for the data that fping needs to do

its work (sequence number, timestamp). The reported received data size includes the IP header (normally 20 bytes)

and ICMP header (8 bytes), so the minimum total size is 40 bytes. Default is 56, as in ping. Maximum is the theom

retical maximum IP datagram size (64K), though most systems limit this to a smaller, system-dependent number.

-Bn In the default mode, fping sends several requests to a target before giving up, waiting longer for a reply on each

successive request. This parameter is the value by which the wait time is multiplied on each successive request; it

must be entered as a floating-point number (x.y). The default is 1.5.

-c Number of request packets to send to each target. In this mode, a line is displayed for each received response (this

can suppressed with -q or -Q). Also, statistics about responses for each target are displayed when all requests have

been sent (or when interrupted).

-C Similar to -c, but the per-target statistics are displayed in a format designed for automated response-time statism

tics gathering. For example:

% fping -C 5 -q somehost

somehost : 91.7 37.0 29.2 - 36.8

shows the response time in milliseconds for each of the five requests, with the ”-” indicating that no response was

received to the fourth request.

-d Use DNS to lookup address of return ping packet. This allows you to give fping a list of IP addresses as input and

print hostnames in the output.

-e Show elapsed (round-trip) time of packets

-f Read list of targets from a file. This option can only be used by the root user. Regular users should pipe in the

file via stdin:

% fping < targets_file

-g Generate a target list from a supplied IP netmask, or a starting and ending IP. Specify the netmask or start/end in

the targets portion of the command line.

ex. To ping the class C 192.168.1.x, the specified command line could look like either:

fping -g 192.168.1.0/24

or

fping -g 192.168.1.0 192.168.1.255

-h Print usage message.

-in The minimum amount of time (in milliseconds) between sending a ping packet to any target (default is 25).

-l Loop sending packets to each target indefinitely. Can be interrupted with ctl-C; statistics about responses for each

target are then displayed.

-m Send pings to each of a target host’s multiple interfaces.

-n Same as -d.

-p In looping or counting modes (-l, -c, or -C), this parameter sets the time in milliseconds that fping waits between

successive packets to an individual target. Default is 1000.

-q Quiet. Don’t show per-target results, just set final exit status.

-Qn Like -q, but show summary results every n seconds.

-rn Retry limit (default 3). This is the number of times an attempt at pinging a target will be made, not including the

first try.

-s Print cumulative statistics upon exit.

-Saddr

Set source address.

-tn Initial target timeout in milliseconds (default 500). In the default mode, this is the amount of time that fping

waits for a response to its first request. Successive timeouts are multiplied by the backoff factor.

-Tn Select timeout in seconds (default 10).

-u Show targets that are unreachable.

-v Print fping version information.

fping使用示例:

goface ~ # fping -a -g 192.168.1.2 192.168.1.35

192.168.1.8

192.168.1.32

ICMP Host Unreachable from 192.168.1.32 for ICMP Echo sent to 192.168.1.2

ICMP Host Unreachable from 192.168.1.32 for ICMP Echo sent to 192.168.1.2

ICMP Host Unreachable from 192.168.1.32 for ICMP Echo sent to 192.168.1.2

ICMP Host Unreachable from 192.168.1.32 for ICMP Echo sent to 192.168.1.3

。。。。。。

192.168.1.8 192.168.1.32 是alive的。

您可以把想测试的IP写入一个文档中,一行一个ip,如ip.txt fping可以直接读取文档中的IP列表。

#fping -a -f ip.txt

当然也支持将结果输出到一个文件中。如

fping -a -g 192.168.1.2 192.168.1.100 -s -n >hosts

-n和-d参数可以查找出主机名。

本文完,更多的技巧还要靠大家自己挖掘。

linux
相关资讯       fping 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款