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
參考