May 23
Cool function you can use on your local network to lookup a devices MAC address, (assuming the device is on your network).
For a big company, either look in the remote locations router, or your core router.  If you use this leave me a comment, would love to know how your using it.
// =============================================
// getmac(Device IP, Router, SNMP Read Community)
//  Michael Requeny — http://michael.requeny.com
// – Looks up remote devices MAC
// – SNMP to routers ARP table
// – Converts MAC from HEX to ASCII
// – Inserts : seperators
// =============================================
function getmac($ip, $router, $snmpread) {
$oid = “.1.3.6.1.2.1.3.1.1.2”;
$mac = snmprealwalk($router, $snmpread, $oid, 1000000 ,10);
// load up array keys for lookups
$keys = array_keys($mac);
foreach ($keys as $key) {
// if needle contains IP && needle = IP
// this prevents srch for 10.254.254.1 returning
// multiple values (like .1, .11, .111, etc.
if (strstr($key,$ip) == $ip) {
$mackey = $key;
}
}
$mac = trim(str_replace(‘Hex-STRING: ‘, ”, $mac));
$mac = str_replace(‘ ‘, ‘:’, $mac);
return $mac;
}