Fping程序类似于ping。Fping与ping不同的地方在于,fping可以在命令行中指定要ping的主机数量范围,也可以指定含有要ping的主机列表文件。
与ping要等待某一主机连接超时或发回反馈信息不同,fping给一个主机发送完数据包后,马上给下一个主机发送数据包,实现多主机同时ping。如果某一主机ping通,则此主机将被打上标记,并从等待列表中移除,如果没ping通,说明主机无法到达,主机仍然留在等待列表中,等待后续操作。
PS:(ping是通过ICMP(网络控制信息协议InternetControl Message Protocol)协议回复请求以检测主机是否存在)
下载地址: http://sourceforge.net/projects/fping/
http://download.youkuaiyun.com/detail/taotianjin/6382635
官方网站: http://fping.sourceforge.net/
功能
fping - send ICMP ECHO_REQUEST packets tonetwork hosts
UNIX和Windows环境都有许多可以用来进行ICMPping扫描的工具。fping是UNIX环境里久经考验的ping扫描工具之一。早期的ping扫描工具大都需要等待前一个被探测主机返回某种响应消息之后才能继续探测下一台主机是否存在,但fping却能以轮转方式并行地发出大量的ping请求。这么一来,用fping工具去扫描多个IP地址的速度要比ping快很多。
跟普通shell批量ping脚本相比,具有并行,结果易读的优点
用法
fping工具有两种用法:
1. 可以通过标准输入设备(STDIN)向它提供一系列IP地址作为输入。
2. 可以让它去读取某个文件。让fping工具去读取一个文件是件很简单的事情:创建一个文本文件并把IP地址按每行一个的格式写入,如下所示:
创建文本:in.txt,内容如下:
192.168.51.1
192.168.51.2
192.168.51.3
...
192.168.51.253
192.168.51.254
然后使用“-f”参数读入这个文件,如下所示:
[root]$ fping –a –f in.txt
192.168.1.254 is alive
192.168.1.227 is alive
192.168.1.224 is alive
...
192.168.1.3 is alive
192.168.1.2 is alive
192.168.1.1 is alive
192.168.1.190 is alive
参数说明
fping工具的参数说明:
参数 | 说明 |
-a | Lists targets that responded 显示可ping通的目标 |
-A | Lists targets by address instead of hostname 将目标以ip地址的形式显示 |
-b <num> | Sends <num> bytes of data per ICMP packet (default 56) ping 数据包的大小。(默认为56) |
-B <f> | Tells fping to wait <f> times longer for a reply after each successive failed request (default 1.5) 设置指数反馈因子到f |
-c <num> | Number of Pings to send to each target (default 1) ping每个目标的次数 (默认为1) |
-C <num> | Same as above but prints additional statistics for each host 同-c,返回的结果为冗长格式 |
-e | Displays elapsed time on return packets 显示返回数据包所费时间 |
-f <file> | Reads the target list from <file> (use "-" for standard input) (only if no -g specified) 从文件获取目标列表( - 表示从标准输入)(不能与 -g 同时使用) |
-g | Tells fping to generate a target list by specifying the start and end address (ex. ./fping -g 192.168.1.0 192.168.1.255) or an IP/subnet mask (ex. ./fping -g 192.168.1.0/24) 通过指定开始和结束地址来生成目标列表(例如:./fping –g 192.168.1.0 192.168.1.255)或者一个IP/掩码形式(例如:./fping –g 192.168.1.0/24) |
-i <num> | Interval (in milliseconds) to wait between Pings (default 25) 设置ip的TTL值 (生存时间) |
-l | Sends Pings forever 循环发送ping |
-m | Pings multiple interfaces on target host ping目标主机的多个网口 |
-n | Displays targets by name (-d is equivalent) 将目标以主机名或域名显示(等价于 -d ) |
-p <num> | Interval (in milliseconds) between Pings to an individual target (in looping and counting modes, default 1000) 对同一个目标的ping包间隔(毫秒) (在循环和统计模式中,默认为1000) |
-q | Doesn't show per-target/per-Ping results 安静模式(不显示每个目标或每个ping的结果) |
-Q <num> | Same as -q, but show summary every <num> seconds 同-q, 但是每n秒显示信息概要 |
-r <num> | When a host doesn't respond, retries the host <num> times (default 3) 当ping失败时,最大重试次数(默认为3次) |
-s | Displays summary statistics 打印最后的统计数据 |
-t <num> | Timeout (in milliseconds) for individual targets (default 500) 单个目标的超时时间(毫秒)(默认500) |
-u | Displays targets that are unreachable 显示不可到达的目标 |
-v | Displays version number 显示版本号 |
安装
[root@bogon fping-3.4]# pwd
/usr/local/src/fping-3.4
[root@bogon fping-3.4]# ls
aclocal.m4 config.h.in configure.ac doc Makefile.am README
ChangeLog config.sub COPYING INSTALL Makefile.in src
config.guess configure depcomp install-sh missing
[root@bogon fping-3.4]# vi README
[root@bogon fping-3.4]# ./configure
[root@bogon fping-3.4]# make
[root@bogon fping-3.4]# make install
测试命令
[root@bogon fping-3.4]# fping x.x.x.x
x.x.x.x is alive
[root@bogon fping-3.4]# vi in.txt
[root@bogon fping-3.4]# fping -f in.txt
202.x.x.x is alive
10.x.x.x is alive
www.baidu.com is alive