Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.%i | FIND /I "Reply">> c:\lanipaddresses.txt

Thanks!

like image 900
JShoe Avatar asked Mar 23 '11 22:03

JShoe


3 Answers

For Linux machines, how about good old Nmap:

nmap -sP 192.168.2.* 
like image 139
pinpox Avatar answered Nov 02 '22 23:11

pinpox


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
like image 29
RDL Avatar answered Nov 03 '22 00:11

RDL


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

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

like image 22
Eric Avatar answered Nov 03 '22 00:11

Eric