Obtaining all MAC addresses on a network

November 25, 2010 at 10:01:34
Specs: Windows XP
Hi,

I am trying to develop a script that will bring back the corresponding MAC address to a range of ip addresses and then out put that data to a file.

Here is what i have so far;

@echo off

SET t=0

Echo Results correct as of %Date% %Time% >> "C:\MacAdds.txt"

:start

SET /a t=t+1

GETMAC /FO TABLE /S 10.42.7.%t% > nul >> "C:\MacAdds.txt"

IF %t%==256 Exit

Goto start


It works when just doing a standard ping rather than the GETMAC command.

I dont know where im going wrong so any help would be great!!

Thanks


See More: Obtaining all MAC addresses on a network

Report •


#1
November 26, 2010 at 00:35:29
Try this one..

@echo off
SETLOCAL ENABLEDELAYEDEXPANSION


SET t=0
Echo Results correct as of %Date% %Time% >>yourtextfile.txt
:start
SET /a t=t+1


GETMAC /FO TABLE /S 192.168.2.%t% >>yourtextfile.txt
IF %t%==256 Exit


Goto start

Subhash Chandra.


Report •

#2
November 26, 2010 at 01:05:17
Try;

@echo off
FOR /L %%i in (1,1,254) do GETMAC /FO TABLE /S 192.168.2.%%i >> yourtextfile.txt
pause
exit

Happy is ONE who says I am an OttoMAN.


Report •

#3
November 28, 2010 at 07:23:37
Thnanks for this tip..this is easier then anything.

Subhash Chandra.


Report •

Related Solutions

#4
November 29, 2010 at 01:53:47
use this tool Find MAC Address

Report •

#5
December 1, 2010 at 13:20:27
Use nmap

example:
C:\>nmap -sP 192.168.0.0/24

That will do a ping sweep of the network and return the IP address, MAC address, and DNS name if it can be resolved.


Report •

Ask Question