将ping发送到子网上的每个IP [英] Send a ping to each IP on a subnet
问题描述
是否存在基于命令行的方法,可将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 与mask选项一起使用,因为您不希望自己只能进行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
来自男人:
fping 与 ping 的不同之处在于,您可以指定任意数量的目标 在命令行上,或指定一个包含目标列表的文件 ping.而不是发送到一个目标,直到它超时或 回复, 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/
这篇关于将ping发送到子网上的每个IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!