windows 查找计算机IP,查找局域网内所有计算机的IP

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5412656/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 16:29:29  来源:igfitidea点击:

Find IP of computer, find IPs of all computers on LAN

windowsbatch-filecmdip

提问by JShoe

I know how to find a computer's IP address, but how do I make a variable set as the IP address of that computer, or save it to a text file, all in a batch?

我知道如何查找计算机的 IP 地址,但是如何将变量设置为该计算机的 IP 地址,或将其保存到文本文件中,所有这些都是批处理?

Also, I found a line of code on the internet that would ping every possible IP address of a given server and list the IPs successfully pinged, but it didn't work; they all timed out. What would be wrong with it? Is there a better way to do it? So here's the code for that:

另外,我在 Internet 上找到了一行代码,可以 ping 给定服务器的每个可能的 IP 地址并列出成功 ping 的 IP,但它不起作用;他们都超时了。它会有什么问题?有没有更好的方法来做到这一点?所以这是代码:

FOR /L %i IN (1,1,254) DO ping --a --n 1 10.0.1.%i | FIND /I "Reply">> c:\lanipaddresses.txt

Thanks!

谢谢!

采纳答案by RDL

You need to change the 10.0.1.%to what your IP set would be.

您需要将 更改10.0.1.%为您的 IP 集。

ie. this script won't work a 192.168.1.%network as is. For this set use:

IE。此脚本无法192.168.1.%按原样在网络中工作。对于这个集合使用:

updated

更新

FOR /L %i IN (1,1,254) DO ping -n 1 10.0.1.%i | FIND /i "Reply">> c:\lanipaddresses.txt

回答by pinpox

For Linux machines, how about good old Nmap:

对于 Linux 机器,好的旧 Nmap 怎么样:

nmap -sP 192.168.2.* 

回答by Eric

For Windows machines, how about good old arp:
arp -a

对于 Windows 机器,好的旧 arp 怎么样:
arp -a

Obviously the question was FOR /L %Windows IN (3,1, 10)

显然问题是 FOR /L %Windows IN (3,1, 10)