向子网上的每个 IP 发送 ping [英] Send a ping to each IP on a subnet

查看:17
本文介绍了向子网上的每个 IP 发送 ping的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有基于命令行的方式来向子网中的每台计算机发送 ping?喜欢

Is there a command line based way to send pings to each computer in a subnet? Like

for(int i = 1; i < 254; i++)
    ping(192.168.1.i);

强制解析arp?

推荐答案

我建议将 fping 与掩码选项一起使用,因为您不会限制自己使用 ping.

I would suggest the use of fping with the mask option, since you are not restricting yourself in ping.

fping -g 192.168.1.0/24

响应将很容易在脚本中解析:

The response will be easy to parse in a script:

192.168.1.1 is alive
192.168.1.2 is alive
192.168.1.3 is alive
192.168.1.5 is alive
...
192.168.1.4 is unreachable
192.168.1.6 is unreachable
192.168.1.7 is unreachable
...

注意:使用参数 -a 会将输出限制为可访问的 ip 地址,您可能需要使用它,否则 fping 也会打印无法访问的地址:

Note: Using the argument -a will restrict the output to reachable ip addresses, you may want to use it otherwise fping will also print unreachable addresses:

fping -a -g 192.168.1.0/24

来自人:

fpingping 的不同之处在于您可以指定任意数量的目标在命令行上,或指定一个包含目标列表的文件平.而不是发送到一个目标,直到它超时或回复,fping 将发送一个 ping 数据包并移动到下一个以循环方式定位.

fping differs from ping in that you can specify any number of targets on the command line, or specify a file containing the lists of targets to ping. Instead of sending to one target until it times out or replies, fping will send out a ping packet and move on to the next target in a round-robin fashion.

更多信息:http://fping.org/

这篇关于向子网上的每个 IP 发送 ping的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆