The question often comes up, how do you find out the MAC address of a remote machine, given its IP address? There are a few ways to do it, but here are two:
- The first way is to use SNMP. Use whatever SNMP library you like, or create your own. Here are the steps you'll need to take, as well as an example showing how to implement these steps using IP*Works! or IPWorks Secure SNMP.
- Get the number of interfaces on the device (ifEntryNum - 1.3.6.1.2.1.2.1)
- For each interface, get the MAC address (ifPhysAddress - 1.3.6.1.2.1.2.2.1.6). You can also determine a lot of other information about the interface (the ifEntry table has several children) including the type of the device (ifEntryType - 1.3.6.1.2.1.2.2.1.3).
Example:
- The second way requires the use of the IPWorks IPInfo component, which has a GetMAC method. This method takes an IP address as its argument and returns a string, which is the MAC address of the device at the remote IP. Example: