• 计算机网络实用工具之fping


    简介

    fping是一个类似ping的程序,它使用互联网控制消息协议(ICMP)回显请求来确定目标主机是否正在响应。fping与ping的不同之处在于,您可以在命令行上指定任意数量的目标,或者指定一个包含要ping的目标列表的文件。fping将发送一个ping数据包,并以循环方式移动到下一个目标,而不是发送到一个目标直到它超时或回复。

    安装

    1. # 例ubuntu
    2. sudo apt install fping
    3. # centos 7
    4. sudo yum install fping

    使用帮助

    1. # fping -h
    2. Usage: fping [options] [targets...]
    3. Probing options:
    4. -4, --ipv4 only ping IPv4 addresses
    5. -6, --ipv6 only ping IPv6 addresses
    6. -b, --size=BYTES amount of ping data to send, in bytes (default: 56)
    7. -B, --backoff=N set exponential backoff factor to N (default: 1.5)
    8. -c, --count=N count mode: send N pings to each target
    9. -f, --file=FILE read list of targets from a file ( - means stdin)
    10. -g, --generate generate target list (only if no -f specified)
    11. (give start and end IP in the target list, or a CIDR address)
    12. (ex. fping -g 192.168.1.0 192.168.1.255 or fping -g 192.168.1.0/24)
    13. -H, --ttl=N set the IP TTL value (Time To Live hops)
    14. -I, --iface=IFACE bind to a particular interface
    15. -l, --loop loop mode: send pings forever
    16. -m, --all use all IPs of provided hostnames (e.g. IPv4 and IPv6), use with -A
    17. -M, --dontfrag set the Don't Fragment flag
    18. -O, --tos=N set the type of service (tos) flag on the ICMP packets
    19. -p, --period=MSEC interval between ping packets to one target (in ms)
    20. (in loop and count modes, default: 1000 ms)
    21. -r, --retry=N number of retries (default: 3)
    22. -R, --random random packet data (to foil link data compression)
    23. -S, --src=IP set source address
    24. -t, --timeout=MSEC individual target initial timeout (default: 500 ms,
    25. except with -l/-c/-C, where it's the -p period up to 2000 ms)
    26. Output options:
    27. -a, --alive show targets that are alive
    28. -A, --addr show targets by address
    29. -C, --vcount=N same as -c, report results in verbose format
    30. -d, --rdns show targets by name (force reverse-DNS lookup)
    31. -D, --timestamp print timestamp before each output line
    32. -e, --elapsed show elapsed time on return packets
    33. -i, --interval=MSEC interval between sending ping packets (default: 10 ms)
    34. -n, --name show targets by name (reverse-DNS lookup for target IPs)
    35. -N, --netdata output compatible for netdata (-l -Q are required)
    36. -o, --outage show the accumulated outage time (lost packets * packet interval)
    37. -q, --quiet quiet (don't show per-target/per-ping results)
    38. -Q, --squiet=SECS same as -q, but add interval summary every SECS seconds
    39. -s, --stats print final stats
    40. -u, --unreach show targets that are unreachable
    41. -v, --version show version
    42. -x, --reachable=N shows if >=N hosts are reachable or not

    使用示例

    1. # 测试多个主机是否可达
    2. # fping 8.8.8.8 www.google.com
    3. 8.8.8.8 is alive
    4. www.google.com is alive
    5. # 指定次数测试多个主机,显示延时等信息
    6. # fping -c 3 8.8.8.8 www.google.com
    7. 8.8.8.8 : [0], 64 bytes, 1.52 ms (1.52 avg, 0% loss)
    8. www.google.com : [0], 64 bytes, 1.79 ms (1.79 avg, 0% loss)
    9. 8.8.8.8 : [1], 64 bytes, 1.55 ms (1.54 avg, 0% loss)
    10. www.google.com : [1], 64 bytes, 1.78 ms (1.78 avg, 0% loss)
    11. 8.8.8.8 : [2], 64 bytes, 1.54 ms (1.54 avg, 0% loss)
    12. www.google.com : [2], 64 bytes, 1.74 ms (1.77 avg, 0% loss)
    13. 8.8.8.8 : xmt/rcv/%loss = 3/3/0%, min/avg/max = 1.52/1.54/1.55
    14. www.google.com : xmt/rcv/%loss = 3/3/0%, min/avg/max = 1.74/1.77/1.79
    15. # 从文件读取主机列表
    16. # cat test.list
    17. # dns
    18. 8.8.8.8
    19. # google
    20. www.google.com
    21. # fping -c 3 -f test.list
    22. 8.8.8.8 : [0], 64 bytes, 1.52 ms (1.52 avg, 0% loss)
    23. www.google.com : [0], 64 bytes, 1.84 ms (1.84 avg, 0% loss)
    24. 8.8.8.8 : [1], 64 bytes, 1.46 ms (1.49 avg, 0% loss)
    25. www.google.com : [1], 64 bytes, 1.77 ms (1.81 avg, 0% loss)
    26. 8.8.8.8 : [2], 64 bytes, 1.48 ms (1.49 avg, 0% loss)
    27. www.google.com : [2], 64 bytes, 1.76 ms (1.79 avg, 0% loss)
    28. 8.8.8.8 : xmt/rcv/%loss = 3/3/0%, min/avg/max = 1.46/1.49/1.52
    29. www.google.com : xmt/rcv/%loss = 3/3/0%, min/avg/max = 1.76/1.79/1.84

    种草

    本文为"计算机网络实用工具系列"的内容之一,会持续更新其它相关博文

    我的博文内容主要针对“计算机网络”、“安全”、“运维”和“云计算”方向,感兴趣朋友的请关注我,我将不定期发布新的博文并不断改进已发布博文。

    后期依据大家对博文的评论,点赞及关注情况,针对大家感兴趣的内容我也会录制视频并整理出成套的学习资料免费分享给大家,期待能和大家一起交流学习。

  • 相关阅读:
    AST2500常用操作命令
    征稿丨IJCAI‘23大模型论坛,优秀投稿推荐AI Open和JCST发表
    Linux入门:Windows上虚拟机VMware安装Ubuntu系统
    一文带你入门微服务,通俗易懂
    Qt学习--构造函数&析构函数
    JavaScript系列从入门到精通系列第二十篇:使用工厂方法创建JavaScript对象,JavaScript构造函数详解,JavaScript类概念的介绍
    linux-安装nginx(函内网安装方式)
    (cf)Codeforces Round #825 (Div. 2)ABC(BC详细解释)
    代理IP与Socks5代理在网络安全与数据隐私中的关键作用
    MySQL学习记录(7)SQL优化
  • 原文地址:https://blog.csdn.net/hougang/article/details/134538812