Re: how to discover MAC address?

Raul Miller (rmiller@aspensys.com)
Tue, 15 Jul 1997 20:57:58 -0400

Doug Hughes <Doug.Hughes@Eng.Auburn.EDU> wrote:
> >i'd like to determine the hardware address for given a host IP address and
> >the appropriate router IP address.

To do this right, you need to maintain a database of known
ip address/mac pairs. Here's a quick-and-dirty script
to poll a specific router for its arp table. [It seems
easier, to me, to set up one of these scripts for each router
than to parameterize this script.]:

#!/bin/sh
# turn control over to scotty -*- tcl -*- \
scotty2.1.5 "$0" "$@" | cut -d. -f13-; exit

package require Tnm 2.1
set s [snmp session -community _____________ -address _______]

$s walk x atTable {
set y [lindex $x 0]
set oid [lindex $y 0]
switch -glob $oid "1.3.6.1.2.1.3.1.1.2.*" {
set mac [lindex $y 2]
puts "$oid $mac"
} "1.3.6.1.2.1.3.1.1.3.*" { exit }
}

By running this periodically, you can aquire a reasonably
up-to-date list of active ip/mac pairs.

Depending on your application, you may need to normalize
the mac address format.

-- 
Raul
--
!! This message is brought to you via the `tkined & scotty' mailing list.
!! Please do not reply to this message to unsubscribe. To subscribe or
!! unsubscribe, send a mail message to <tkined-request@ibr.cs.tu-bs.de>.
!! See http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/ for more information.