cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3646
Views
5
Helpful
7
Replies

Using MAC OUI to trigger EEM Macro

VRizk
Level 1
Level 1

I'm pretty new to using EEM and in the process of learning. My goal is to use EEM to detect phones using the OUI of the mac address (cdp won't work as the phones used aren't cisco) and then when it detects that particular OUI on an interface it will set the vlan, speed and duplex. I figured to do this I would enter the following:

 

event manager applet AVAYA-EVENT
event mat interface regexp GigabitEthernet.*
event mat mac-address 0004.0d
action 001 cli command "enable"
action 002 cli command "config t"
action 003 cli command "interface $_mat_intf_name"
action 004 cli command "switchport access vlan 210"
action 005 cli command "switchport voice vlan 5"
action 006 cli command "switchport mode access"
action 006 cli command "speed 100"
action 007 cli command "duplex full"
action 008 cli command "no shutdown"
action 008 cli command "end"
end

 

However this isn't working. 

 

I also tried by doing the following:

macro auto mac-address-group AVAYA-PHONE
oui list 00040d
end

And then using the build in Cisco macro to see if it would atleast trigger:

macro auto execute AVAYA-PHONE builtin CISCO_PHONE_AUTO_SMARTPORT $ACCESS_VLAN=210 $VOICE_VLAN=5

 

That also didn't work. Am I at least on the right track with the first one? Any help would be greatly appreciated. I used a mix of what I've seen in other posts but still no luck. 

1 Accepted Solution

Accepted Solutions

I forgot a line, but you may want to enable "debug event manager detect mat" and "debug event manager action cli" to see what is happening:

event manager applet LAPTOP-EVENT
event mat interface regexp GigabitEthernet.* type add

action 001 regexp "c8d3.ff" $_mat_mac_address

action 002 if $_regexp_result eq 1
action 003 cli command "enable"
action 004 cli command "config t"
action 005 cli command "interface $_mat_intf_name"
action 006 cli command "switchport access vlan 210"
action 007 cli command "speed auto"
action 008 cli command "duplex auto"
action 009 cli command "no shutdown"
action 010 cli command "end"

action 011 end

View solution in original post

7 Replies 7

Joe Clarke
Cisco Employee
Cisco Employee

What you've configured will not work.  What version of IOS do you have and on what switch?

I'm using a 3560X POE switch version 12.2(55)SE8.

You can do this, then:

event manager applet AVAYA-EVENT
event mat interface regexp GigabitEthernet.*

action 001 regexp "0004.0d" $_mat_mac_address

action 002 if $_regexp_result eq 1
action 003 cli command "enable"
action 004 cli command "config t"
action 005 cli command "interface $_mat_intf_name"
action 006 cli command "switchport access vlan 210"
action 007 cli command "switchport voice vlan 5"
action 008 cli command "switchport mode access"
action 009 cli command "speed 100"
action 010 cli command "duplex full"
action 011 cli command "no shutdown"
action 012 cli command "end"
end

Hmmm I tried that and it didn't work. Even tried by connecting my laptop and making another of that nature doing :

event manager applet LAPTOP-EVENT
event mat interface regexp GigabitEthernet.*

action 001 regexp "c8d3.ff" $_mat_mac_address

action 002 if $_regexp_result eq 1
action 003 cli command "enable"
action 004 cli command "config t"
action 005 cli command "interface $_mat_intf_name"
action 006 cli command "switchport access vlan 210"
action 007 cli command "speed auto"
action 008 cli command "duplex auto"
action 009 cli command "no shutdown"
action 010 cli command "end"
end

 

Made sure I can ping the switch from my laptop and that the switch had my mac address stored on the interface which it did. No luck on it changing anything though.

I forgot a line, but you may want to enable "debug event manager detect mat" and "debug event manager action cli" to see what is happening:

event manager applet LAPTOP-EVENT
event mat interface regexp GigabitEthernet.* type add

action 001 regexp "c8d3.ff" $_mat_mac_address

action 002 if $_regexp_result eq 1
action 003 cli command "enable"
action 004 cli command "config t"
action 005 cli command "interface $_mat_intf_name"
action 006 cli command "switchport access vlan 210"
action 007 cli command "speed auto"
action 008 cli command "duplex auto"
action 009 cli command "no shutdown"
action 010 cli command "end"

action 011 end

Thank you that worked!! Just out of curiosity I see it runs it three times before stopping is that normal? (ignore the date):

*Mar 1 00:07:54.342: %PARSER-5-CFGLOG_LOGGEDCMD: User:unknown user logged command:interface GigabitEthernet0/9
*Mar 1 00:07:54.476: %PARSER-5-CFGLOG_LOGGEDCMD: User:unknown user logged command:switchport access vlan 210
*Mar 1 00:07:54.602: %PARSER-5-CFGLOG_LOGGEDCMD: User:unknown user logged command:speed auto
*Mar 1 00:07:54.635: %PARSER-5-CFGLOG_LOGGEDCMD: User:unknown user logged command:duplex auto
*Mar 1 00:07:54.660: %PARSER-5-CFGLOG_LOGGEDCMD: User:unknown user logged command:no shutdown
*Mar 1 00:07:54.786: %SYS-5-CONFIG_I: Configured from console by on vty0 (EEM:LAPTOP-EVENT)
*Mar 1 00:08:09.961: %PARSER-5-CFGLOG_LOGGEDCMD: User:unknown user logged command:interface GigabitEthernet0/9
*Mar 1 00:08:09.995: %PARSER-5-CFGLOG_LOGGEDCMD: User:unknown user logged command:switchport access vlan 210
*Mar 1 00:08:10.096: %PARSER-5-CFGLOG_LOGGEDCMD: User:unknown user logged command:speed auto
*Mar 1 00:08:10.213: %PARSER-5-CFGLOG_LOGGEDCMD: User:unknown user logged command:duplex auto
*Mar 1 00:08:10.238: %PARSER-5-CFGLOG_LOGGEDCMD: User:unknown user logged command:no shutdown
*Mar 1 00:08:10.381: %SYS-5-CONFIG_I: Configured from console by on vty0 (EEM:LAPTOP-EVENT)

It could be as spanning-tree is renegotiated for the new VLAN and the MAC is learned a number of times.

Review Cisco Networking for a $25 gift card