Patrick
Patrick

Reputation: 2577

Get the ip address using the mac address on a networked device

If I know the mac address of a device on a local network, and I know part of the ip address (192.168.112.???), can I find the last 3 numbers using any type of web technology? The device is an ip phone on a vpn with the web server.

Upvotes: 1

Views: 282

Answers (2)

Mark A Kruger
Mark A Kruger

Reputation: 7193

This would work on a windows environment. Using CFEXECUTE run a batchfile containing this the command:

C:\>arp -g

The CF code would look something like:

<cfexecute name="arp.bat" variable="arpAddresses"/>

You might also have to experiment with adding an enterface to that command if you have multiple IPs registered on the card. The results will look like this.

Interface: 10.0.0.21 --- 0xc
  Internet Address      Physical Address      Type
  10.0.0.4              dc-0e-a1-34-c6-5e     dynamic
  10.0.0.6              00-26-2d-7d-b6-ae     dynamic
  10.0.0.8              8c-89-a5-54-4b-e8     dynamic
  10.0.0.9              84-8f-69-aa-10-2d     dynamic
  10.0.0.11             00-15-5d-00-32-03     dynamic
  10.0.0.14             00-8c-fa-3f-56-8e     dynamic
  10.0.0.15             00-15-5d-00-32-12     dynamic
  10.0.0.22             78-ac-c0-a4-fd-17     dynamic
...

They are separated by spaces belive with the MAC address always occuring at line 63? You'll have to experiment with that. Using this data you should be able to build a query or structure or array or whatever and tease out which IP belongs to which IP.

I would add that there are some java libraries that allow access to the stack and would likely get you there as well.

Upvotes: 4

Brad Wood
Brad Wood

Reputation: 3953

If both devices are on the same local network, you could try iterating over each IP in the last octet (1-254) and pinging, and then parsing the output of your OS's ARP command to look at the MAC addresses.

http://compnetworking.about.com/od/tcpip/f/convertmacipadd.htm

Disclaimer, I've never tried this so YMMV

Upvotes: 2

Related Questions