Ping 网络、windows 中的所有地址
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13713318/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Ping all addresses in network, windows
提问by Fantastic Mr Fox
Is it possible in windows cmd line to check all of the network addresses (with ping or similar) to see which ones are taken/ have active devices:
是否可以在 windows cmd 行中检查所有网络地址(使用 ping 或类似方法)以查看哪些已被占用/具有活动设备:
ie. something that does something like the following:
IE。执行以下操作的东西:
for i = 0 to 255
ping 192.168.1.i //Print this
end
This is psuedo code obviously. I am wondering if it is possible to do something like this in windows cmd. It would be great if you didn't need a batch file, but i understand if this is impossible.
这显然是伪代码。我想知道是否有可能在 windows cmd 中做这样的事情。如果您不需要批处理文件,那就太好了,但我知道这是不可能的。
PS. Also please mention if there is a program to do this, but it would be nice to do it in cmd.
附注。另请提及是否有程序可以执行此操作,但最好在 cmd 中执行此操作。
回答by RGG
Open the Command Prompt and type in the following:
打开命令提示符并输入以下内容:
FOR /L %i IN (1,1,254) DO ping -n 1 192.168.10.%i | FIND /i "Reply">>c:\ipaddresses.txt
Change 192.168.10 to match you own network.
更改 192.168.10 以匹配您自己的网络。
By using -n 1 you are asking for only 1 packet to be sent to each computer instead of the usual 4 packets.
通过使用 -n 1,您只要求向每台计算机发送 1 个数据包,而不是通常的 4 个数据包。
The above command will ping all IP Addresses on the 192.168.10.0 network and create a text document in the C:\ drive called ipaddresses.txt.? This text document should only contain IP Addresses that replied to the ping request.
上述命令将 ping 192.168.10.0 网络上的所有 IP 地址并在 C:\ 驱动器中创建一个名为 ipaddresses.txt 的文本文档。此文本文档应仅包含回复 ping 请求的 IP 地址。
Although it will take quite a bit longer to complete, you can also resolve the IP Addresses to HOST names by simply adding -a to the ping command.
虽然完成需要更长的时间,但您也可以通过简单地将 -a 添加到 ping 命令来将 IP 地址解析为主机名称。
FOR /L %i IN (1,1,254) DO ping -a -n 1 192.168.10.%i | FIND /i "Reply">>c:\ipaddresses.txt
This is from Here
这是从这里
Hope this helps
希望这可以帮助
回答by Ed Mackenzie
I know this is a late response, but a neat way of doing this is to ping the broadcast address which populates your local arp cache.
我知道这是一个迟到的响应,但一个巧妙的方法是 ping 填充本地 arp 缓存的广播地址。
This can then be shown by running arp -a which will list all the addresses in you local arp table.
然后可以通过运行 arp -a 来显示这将列出本地 arp 表中的所有地址。
ping 192.168.1.255
arp -a
Hopefully this is a nice neat option that people can use.
希望这是人们可以使用的一个不错的简洁选项。
回答by spetzz
Best Utility in terms of speed is Nmap.
速度方面的最佳实用程序是Nmap。
write @ cmd prompt:
写@cmd提示:
Nmap -sn -oG ip.txt 192.168.1.1-255
Nmap -sn -oG ip.txt 192.168.1.1-255
this will just ping all the ip addresses in the range given and store it in simple text file
这只会ping给定范围内的所有IP地址并将其存储在简单的文本文件中
It takes just 2secs to scan 255hosts using Nmap.
使用 Nmap扫描255 台主机只需2秒。
回答by Paul Allen
This post asks the same question, but for linux - you may find it helpful. Send a ping to each IP on a subnet
这篇文章提出了同样的问题,但对于 linux - 您可能会发现它很有帮助。 向子网上的每个 IP 发送 ping
nmap is probably the best tool to use, as it can help identify host OS as well as being faster. It is available for the windows platform on the nmap.org site
nmap 可能是最好用的工具,因为它可以帮助识别主机操作系统并且速度更快。它可用于 nmap.org 站点上的 windows 平台
回答by Vigbjorn
Provided the windows box is in the same subnet:
如果 Windows 框在同一子网中:
for /L %a in (1,1,254) do start ping 192.168.0.%a
This will complete in less than 15 seconds and
这将在不到 15 秒内完成,并且
arp -a
will return any alive host.
将返回任何活着的主机。
Fastest native way I know of in Windows.
我在 Windows 中所知道的最快的本地方式。
回答by J-Dizzle
An expansion and useful addition to egmackenzie's "arp -a" solution for Windows -
egmackenzie 的“arp -a” Windows 解决方案的扩展和有用的补充 -
Windows Example searching for my iPhone on the WiFi network
在 WiFi 网络上搜索我的 iPhone 的 Windows 示例
(pre: iPhone WiFi disabled)
(前:iPhone WiFi 已禁用)
- Open Command Prompt in Admin mode(R.C. Start & look in menu)
- arp -d <- clear the arp listing!
- ping 10.1.10.255 <- take your subnet, and ping '255', everyone
- arp -a
- iPhone WiFi on
- ping 10.1.10.255
- arp -a
- 在管理员模式下打开命令提示符(RC 开始并查看菜单)
- arp -d <- 清除 arp 列表!
- ping 10.1.10.255 <- 使用你的子网,ping '255',大家
- arp -a
- iPhone WiFi 开启
- 平 10.1.10.255
- arp -a
See below for example:
请参阅以下示例:
Here is a nice writeup on the use of 'arp -d' here if interested -
如果有兴趣,这里有一篇关于使用“arp -d”的好文章 -
回答by Benjamin Trent
All you are wanting to do is to see if computers are connected to the network and to gather their IP addresses. You can utilize angryIP scanner: http://angryip.org/to see what IP addresses are in use on a particular subnet or groups of subnets.
您要做的就是查看计算机是否已连接到网络并收集其 IP 地址。您可以使用angryIP 扫描器:http://angryip.org/查看特定子网或子网组上正在使用的IP 地址。
I have found this tool very helpful when trying to see what IPs are being used that are not located inside of my DHCP.
我发现这个工具在尝试查看正在使用的 IP 不在我的 DHCP 内部时非常有用。
回答by Paul Lammertsma
Some things seem appeared to have changed in batch scripts on Windows 8, and the solution above by DGG now causes the Command Prompt to crash.
Windows 8 上的批处理脚本中的某些内容似乎发生了变化,而 DGG 的上述解决方案现在会导致命令提示符崩溃。
The following solution worked for me:
以下解决方案对我有用:
@echo off
set /a n=0
:repeat
set /a n+=1
echo 192.168.1.%n%
ping -n 1 -w 500 192.168.1.%n% | FIND /i "Reply">>ipaddresses.txt
if %n% lss 254 goto repeat
type ipaddresses.txt
回答by Emiel Duivenvoorden
@ECHO OFF
IF "%SUBNET%"=="" SET SUBNET=10
:ARGUMENTS
ECHO SUBNET=%SUBNET%
ECHO ARGUMENT %1
IF "%1"=="SUM" GOTO SUM
IF "%1"=="SLOW" GOTO SLOW
IF "%1"=="ARP" GOTO ARP
IF "%1"=="FAST" GOTO FAST
REM PRINT ARP TABLE BY DEFAULT
:DEFAULT
ARP -a
GOTO END
REM METHOD 1 ADDRESS AT A TIME
:SLOW
ECHO START SCAN
ECHO %0 > ipaddresses.txt
DATE /T >> ipaddresses.txt
TIME /T >> ipaddresses.txt
FOR /L %%i IN (1,1,254) DO ping -a -n 2 192.168.%SUBNET%.%%i | FIND /i "TTL=" >> ipaddresses.txt
GOTO END
REM METHOD 2 MULTITASKING ALL ADDRESS AT SAME TIME
:FAST
ECHO START FAST SCANNING 192.168.%SUBNET%.X
set /a n=0
:FASTLOOP
set /a n+=1
ECHO 192.168.%SUBNET%.%n%
START CMD.exe /c call ipaddress.bat 192.168.%SUBNET%.%n%
IF %n% lss 254 GOTO FASTLOOP
GOTO END
:SUM
ECHO START SUM
ECHO %0 > ipaddresses.txt
DATE /T >> ipaddresses.txt
TIME /T >> ipaddresses.txt
FOR /L %%i IN (1,1,254) DO TYPE ip192.168.%SUBNET%.%%i.txt | FIND /i "TTL=" >> ipaddresses.txt
FOR /L %%i IN (1,1,254) DO DEL ip192.168.%SUBNET%.%%i.txt
type ipaddresses.txt
GOTO END
:ARP
ARP -a >> ipaddresses.txt
type ipaddresses.txt
GOTO END
:END
ECHO DONE WITH IP SCANNING
ECHO OPTION "%0 SLOW" FOR SCANNING 1 AT A TIME
ECHO OPTION "%0 SUM" FOR COMBINE ALL TO FILE
ECHO OPTION "%0 ARP" FOR ADD ARP - IP LIST
ECHO PARAMETER "SET SUBNET=X" FOR SUBNET
ECHO.