snmp - "get mac" OID

Answered Question
Mar 18th, 2004
User Badges:

Can anyone please tell me how to find the OID that will give me the MAC address of a device connected to port (0-24)?



Thank you!

Sharon


Correct Answer by minie about 13 years 1 month ago

dot1dTpFdbEntry contains three entries and is indexed by dot1dTpFdbAddress.


dot1dTpFdbEntry OBJECT-TYPE

SYNTAX Dot1dTpFdbEntry

ACCESS not-accessible

STATUS mandatory

DESCRIPTION

"Information about a specific unicast MAC address

for which the bridge has some forwarding and/or

filtering information."

INDEX { dot1dTpFdbAddress } <--

::= { dot1dTpFdbTable 1 }


Dot1dTpFdbEntry ::=

SEQUENCE {

dot1dTpFdbAddress <--

MacAddress,

dot1dTpFdbPort <--

INTEGER,

dot1dTpFdbStatus <--

INTEGER

}


1) So you need to poll dot1dTpFdbPort to get the port index number.


nms-server2:/mibs> snmpwalk -c [email protected] 14.32.6.12 dot1dTpFdbPort

BRIDGE-MIB::dot1dTpFdbPort.0.1.66.69.224.255 = INTEGER: 2

BRIDGE-MIB::dot1dTpFdbPort.0.2.126.248.168.87 = INTEGER: 2

BRIDGE-MIB::dot1dTpFdbPort.0.2.185.144.76.102 = INTEGER: 385 <-- portIndex is 385


2) so port index is 385, what's the ifIndex for that port?


nms-server2:/mibs> snmpwalk -c public 14.32.6.12 dot1dBasePortIfIndex | grep 385

BRIDGE-MIB::dot1dBasePortIfIndex.385 = INTEGER: 101 <-- ah, ha, ifIndex is 101


3) now ifIndex is 101, what port is it?


nms-server2:/mibs> snmpwalk -c public 14.32.6.12 ifName | grep 101

IF-MIB::ifName.101 = STRING: 4/1 <-- it's port 4/1


4) verify from CLI


nms-6506a> (enable) show cam dynamic 4/1

* = Static Entry. + = Permanent Entry. # = System Entry. R = Router Entry.

X = Port Security Entry $ = Dot1x Security Entry


VLAN Dest MAC/Route Des [CoS] Destination Ports or VCs / [Protocol Type]

---- ------------------ ----- -------------------------------------------


6 00-02-b9-90-4c-66 4/1 [ALL]


<-- this mac matches 0.2.185.144.76.102

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (2 ratings)
Loading.
sharon669 Fri, 03/19/2004 - 15:06
User Badges:

Hi minie


I don’t have access to this page (yet….)

And I don’t have much knowledge in SNMP

I will be more then happy to get some more info on: dot1dTpFdbEntry


Do I need to send:

1.3.6.1.2.1.17.4.3.1.1

To get port 1 mac

And

1.3.6.1.2.1.17.4.3.1.n


To get port n mac ?


Thank you very much


Sharon .



sharon669 Sun, 03/21/2004 - 00:17
User Badges:

I was able to get the article from a friend,

The article describes problem finding MAC when using Cisco works or ANI ,


I am trying to write a piece of java code that will sample Cisco devices,

And I don’t know the correct OID to send , in order to receive the MAC from each port


Please advice.


Sharon.


sharon669 Mon, 03/22/2004 - 06:05
User Badges:

Hi minie

Thank you for the information,

I am able to receive the entire Mac addresses using 1.3.6.1.2.1.17.4.3.1.1, dot1dTpFdbAddress


My problem is how to attribute each Mac to its port.

I guess I have to dig in the mib file ...


Thank you.

Sharon


Correct Answer
minie Mon, 03/22/2004 - 06:54
User Badges:
  • Bronze, 100 points or more

dot1dTpFdbEntry contains three entries and is indexed by dot1dTpFdbAddress.


dot1dTpFdbEntry OBJECT-TYPE

SYNTAX Dot1dTpFdbEntry

ACCESS not-accessible

STATUS mandatory

DESCRIPTION

"Information about a specific unicast MAC address

for which the bridge has some forwarding and/or

filtering information."

INDEX { dot1dTpFdbAddress } <--

::= { dot1dTpFdbTable 1 }


Dot1dTpFdbEntry ::=

SEQUENCE {

dot1dTpFdbAddress <--

MacAddress,

dot1dTpFdbPort <--

INTEGER,

dot1dTpFdbStatus <--

INTEGER

}


1) So you need to poll dot1dTpFdbPort to get the port index number.


nms-server2:/mibs> snmpwalk -c [email protected] 14.32.6.12 dot1dTpFdbPort

BRIDGE-MIB::dot1dTpFdbPort.0.1.66.69.224.255 = INTEGER: 2

BRIDGE-MIB::dot1dTpFdbPort.0.2.126.248.168.87 = INTEGER: 2

BRIDGE-MIB::dot1dTpFdbPort.0.2.185.144.76.102 = INTEGER: 385 <-- portIndex is 385


2) so port index is 385, what's the ifIndex for that port?


nms-server2:/mibs> snmpwalk -c public 14.32.6.12 dot1dBasePortIfIndex | grep 385

BRIDGE-MIB::dot1dBasePortIfIndex.385 = INTEGER: 101 <-- ah, ha, ifIndex is 101


3) now ifIndex is 101, what port is it?


nms-server2:/mibs> snmpwalk -c public 14.32.6.12 ifName | grep 101

IF-MIB::ifName.101 = STRING: 4/1 <-- it's port 4/1


4) verify from CLI


nms-6506a> (enable) show cam dynamic 4/1

* = Static Entry. + = Permanent Entry. # = System Entry. R = Router Entry.

X = Port Security Entry $ = Dot1x Security Entry


VLAN Dest MAC/Route Des [CoS] Destination Ports or VCs / [Protocol Type]

---- ------------------ ----- -------------------------------------------


6 00-02-b9-90-4c-66 4/1 [ALL]


<-- this mac matches 0.2.185.144.76.102

sharon669 Mon, 03/22/2004 - 23:18
User Badges:

Thank you very much minie


I will follow those steps today, and try to get the mac by port# .


I don't understand why is it so complicated

If I want to get :


Port description

Port speed

Port vlan


It's just sending single (OID + port# ) request and receiving back value

Simple as that


Thanks again

Sharon

sharon669 Mon, 03/29/2004 - 02:59
User Badges:

Hi

I am working in RT env , I'm trying to get the Mac as fast as I can

Is there anyway I can send SNMP command to the switch so it will refresh the dot1dTpFdbAddress table?


Thanks again

Sharon.

minie Mon, 03/29/2004 - 05:38
User Badges:
  • Bronze, 100 points or more

All the MIB objects are updated in real time. You can't "refresh" them.

sharon669 Mon, 03/29/2004 - 12:47
User Badges:

Hi minie

The problem started when the switch is sending a trap (link up), when a computer / Device is connecting to the network Through port n,

When the computer is connected I must do several things,

So I start by reading the Mac from port n , sometimes I am trying to read the Mac from: dot1dTpFdbAddress and I don’t receive it

But if I delay the execution a bit (1sec) I get a result (not always) …


I wonder how it can be possible.

The switch is sending a trap LINKUP trap before the dot1dTpFdbAddress is updated?!?!?!


Should I open new thread for this matter?


10x Thanks

Sharon

minie Mon, 03/29/2004 - 13:08
User Badges:
  • Bronze, 100 points or more

Sharon,


You have to keep in mind the spanning tree protocol. Linkup/linkdown trap is for layer 2 status. As soon as a device/host is connected to it, the trap will be sent. However, STP needs 30 seconds to go thru listening/learning/forwarding state, unless you configured "portfast" on that port.


Well, MIB objects supposed to be updated real time, but depending on implementation, I'm not surprised that it might be seconds delayed.


The bottom line is you can not "refresh" it. There's nothing you can do about it.

Actions

This Discussion