开发者

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

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?

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:

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

Thanks!


For Linux machines, how about good old Nmap:

nmap -sP 192.168.2.* 


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

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

updated

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


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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜