fping的使用简介

fping 的优点:

1. 可以一次ping多个主机

2. 可以从主机列表文件ping

3. 结果清晰 便于脚本处理

4. 速度快

FPING命令详解

在这里插入图片描述
我给大家做了一下翻译

用法:fping[选项][目标…]
调查选项:
仅ping ipv4地址
-6,——ipv6只有ping ipv6地址
-b,——size=要发送的ping数据量,以字节为单位(默认值:56)
-B,——backoff=N设置指数backoff因子为N(默认值:1.5)
计数模式:发送N个ping到每个目标
-f,——file=从文件中读取目标的文件列表(-表示stdin)
生成目标列表(仅当没有指定-f时)
(在目标列表中给出开始和结束IP,或者一个CIDR地址)
(例如:fping -g 192.168.1.0 192.168.1.255或fping -g 192.168.1.0/24)
-H,——ttl=N设置IP ttl值(活跳时间)
-I,——iface= iface绑定到一个特定的接口
-l,——loop loop模式:永远发送ping信号
-m,——所有使用提供的主机名的所有ip(例如IPv4和IPv6),与-A一起使用
-M,——不要设置“不要分割”标志
设置ICMP包上的服务类型(tos)标志
-p,——period= ping包到一个目标之间的MSEC间隔(单位:ms)
(in loop and count mode,默认:1000 ms)
-r,——重试=N次重试(默认:3次)
-R,——随机分组数据(到箔链接数据压缩)
-S,——src=IP设置源地址
-t,——timeout=MSEC单个目标初始超时(默认:500 ms,
除了-l/-c/ -c,其中-p周期为2000 ms)
输出选项:
显示有生命的目标
-A, -addr显示目标地址
-C,——vcount=N与-C相同,以详细格式报告结果
在每个输出行之前打印时间戳
-e,——elapsed显示返回数据包消耗的时间
-i,——interval=发送ping包之间的MSEC间隔(默认值:10 ms)
-n,——name按名称显示目标(-d等效)
-N,——netdata输出兼容netdata (-l -Q是必需的)
-o,——中断显示累计中断时间(丢失包*包间隔)
-q,——非常非常(不要显示每个目标/每个ping的结果)
-Q,——squiet=秒数,与-Q相同,但每n秒显示摘要
-s,——stats打印最终的stats
显示无法达到的目标
-v,——版本显示版本
-x,——可达=N表示>=N个主机是否可达

  -a         show targets that are alive
               显示可ping通的目标
   -A         show targets by address
               将目标以ip地址的形式显示
   -b n       amount of ping data to send, in bytes (default 56)
               ping 数据包的大小。(默认为56)
   -B f       set exponential backoff factor to f
               设置指数反馈因子到f 【这个不懂,求指教~-c n       count of pings to send to each target (default 1)
                ping每个目标的次数 (默认为1)
   -C n       same as -c, report results in verbose format
                同-c, 返回的结果为冗长格式
   -e         show elapsed time on return packets
                显示返回数据包所费时间
   -f file    read list of targets from a file ( - means stdin) (only if no -g specified)
               从文件获取目标列表( - 表示从标准输入)(不能与 -g 同时使用)
   -g         generate target list (only if no -f specified)
               生成目标列表(不能与 -f 同时使用)
                (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)
                (可指定目标的开始和结束IP, 或者提供ip的子网掩码)
                (例:fping -g 192.168.1.0 192.168.1.255 或 fping -g 192.168.1.0/24)
   -H n       Set the IP TTL value (Time To Live hops)
                设置ip的TTL值 (生存时间)
   -i n       interval between sending ping packets (in millisec) (default 25)
               ping包之间的间隔(单位:毫秒)(默认25)
   -l         loop sending pings forever
              循环发送ping
   -m         ping multiple interfaces on target host
                ping目标主机的多个网口
   -n         show targets by name (-d is equivalent)
                将目标以主机名或域名显示(等价于 -d )
   -p n       interval between ping packets to one target (in millisec)
                对同一个目标的ping包间隔(毫秒)
                (in looping and counting modes, default 1000)
                (在循环和统计模式中,默认为1000)
   -q         quiet (don't show per-target/per-ping results)
               安静模式(不显示每个目标或每个ping的结果)
   -Q n       same as -q, but show summary every n seconds
               同-q, 但是每n秒显示信息概要
   -r n       number of retries (default 3)
               当ping失败时,最大重试次数(默认为3次)
   -s         print final stats
               打印最后的统计数据
   -I if      bind to a particular interface
              绑定到特定的网卡
   -S addr    set source address
                  设置源ip地址
   -t n       individual target initial timeout (in millisec) (default 500)
               单个目标的超时时间(毫秒)(默认500)
   -T n       ignored (for compatibility with fping 2.4)
                请忽略(为兼容fping 2.4)
   -u         show targets that are unreachable
                显示不可到达的目标
   -O n       set the type of service (tos) flag on the ICMP packets
                在icmp包中设置tos(服务类型)
   -v         show version
                显示版本号
   targets    list of targets to check (if no -f specified)
                需要ping的目标列表(不能和 -f 同时使用)
-h              show this page
                 显示本帮助页

有用的参数:

-g ping 网段

-s 显示统计

-r 1 设置重试次数

-c ping每个目标的次数

同时ping俩个IP10次

fping IP1 IP2 -c 10

ping只显示结果不显示过程

ping10次122.x.x.x
# fping -A -u -c 10 122.x.x.x
122.x.x.x : xmt/rcv/%loss = 10/10/0%, min/avg/max = 3.16/4.28/6.05

ping某个网段IP

fping -a -g 172.18.9.0/24

参考

原文地址:https://www.cnblogs.com/paul8339/p/15175976.html