how to find IP if I have MAC address
Hi Guys,
I have to find the IP address of a device when I know only the MAC address. Is it possible? The best would be if I can find a bit more - like if it is a computer or printer etc. In this scenario I have only a switch between the devices. Thanks, bojo |
If you know the range of ip addresses like 192.168.0.1 to 50 you could use this bash script to get a list of ip addresses and matching mac addresses.
Also, it's good to know that the first 3 bytes are manufacturer codes. If you look at this site, it may help you identify whether it's a printer or computer. For instance.... 08 00 09 is likely a HP printer. 08 00 09 may be a Matsushita copier/printer. 08 00 37 may be a Fjitsu/Xerox printer of some sort. http://www.synapse.de/ban/HTML/P_LAY.../P_lay207.html To run the script, type: sh scanmac 192.168.0.1 192.168.0.50 _____________________________________________________ #!/bin/bash if [ -z "$1" -o "$1" == "-?" ] ; then echo "Usage: scanmac starting-ip [ending-ip]" echo echo "Will list IP and MAC adresses of all active computers" echo "within a physical network segment." echo echo "If ending-ip is omitted, ending-ip = starting-ip+1" echo " (so that only the host specified will be scanned)." echo echo "If you wish to scan from 192.168.2.1 to 192.168.2.31," echo " inclusive, specify ending-ip to be 192.168.2.32." echo exit 0 fi startw=$(echo "$1" | cut -d. -f1) startx=$(echo "$1" | cut -d. -f2) starty=$(echo "$1" | cut -d. -f3) startz=$(echo "$1" | cut -d. -f4) echo "Starting address: $startw.$startx.$starty.$startz" endip="$2" if [ -z "$endip" ] ; then if [ $startz -eq 255 ] ; then endz=0 if [ $starty -eq 255 ] ; then endy=0 if [ $startx -eq 255 ] ; then endx=0 if [ $startw -eq 255 ] ; then echo "Sorry, you cannot just scan 255.255.255.255." echo " Maybe later, or you can try to hack support in." exit 1 else endw=$(($startw+1)) fi else endx=$(($startx+1)) fi else endy=$(($starty+1)) fi else endz=$(($startz+1)) fi endip=$endw.$endx.$endy.$endz fi echo "Ending address: $endip" currentw=$startw currentx=$startx currenty=$starty currentz=$startz currentip=$currentw.$currentx.$currenty.$currentz # If the bottom octet is zero, it'll get logged inside the while, so # don't do it here if [ "$currentz" -ne "0" ] ; then echo "$(date): $currentip" fi trap "exit 15" 15 trap "exit 2" 2 while [ "$currentip" != "$endip" ] ; do currentip=$currentw.$currentx.$currenty.$currentz # another log message whenever the bottom octet rolls over if [ "$currentz" -eq "0" ] ; then echo "$(date): $currentip" fi ping -c 1 -w 10 $currentip >/dev/null 2>&1 mac=$(arp -a $currentip | cut -d' ' -f4) case "$mac" in ?incomplete?) : # do nothing -- no MAC for this IP ;; entries) : # again, do nothing -- this is a broadcast address ;; *) echo "IP: $currentip -- MAC: $mac" ;; esac mac="" # reset for the next loop iteration # now increment the ip values (w,x,y,z) if [ $currentz -eq 255 ] ; then currentz=0 else currentz=$(($currentz+1)) continue fi if [ $currenty -eq 255 ] ; then currenty=0 else currenty=$(($currenty+1)) continue fi if [ $currentx -eq 255 ] ; then currentx=0 else currentx=$(($currentx+1)) continue fi if [ $currentw -eq 255 ] ; then break else currentz=$(($currentz+1)) continue fi done |
thanks a lot
it works prety good thanks a lot!
|
arp -a will list the MAC and ip addresses of other computers on the LAN that your computer has heard reccently.
|
All times are GMT -5. The time now is 01:16 AM. |