Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. If you'd prefer to explore, try our test area to get started. And see here for current known issues.

New Member

Access Port Only MAT Events

Hello all,

I want to create an applet or EEM script that puts hosts in the proper VLAN based on their mac address/OUI.  I've read through "https://supportforums.cisco.com/document/100791/automatically-set-port-descriptions" and "https://supportforums.cisco.com/discussion/11385521/eem-32-mac-address-prefix-switch-port-config-examples" which are extrememly helpful.  

The big questions are:

1: How would I excluder Trunk interfaces from the EEM event

2: Is it possible to read the mac addresses/OUI's and corresponding VLAN ID's from a csv table rather than configuring each of them as an environment variable?  

aaaa.aa*,20

bbbb.bb*,30

Example, on port G0/1 - G0/20 (access ports)

MAC address aaaa.aa* = VLAN 20

MAC address bbbb.bb* = VLAN 30

event manager environment oui_20 aaaa.aa

event manager environment oui_30 bbbb.bb

!
event manager applet detect-mac
event mat mac-address "^$oui_20"
action 001 syslog msg "detect-mac running"
action 001 cli command "enable"
action 002 cli command "config t"
action 003 cli command "interface $_mat_intf_name"
action 004 if $_mat_notification eq "add"
action 005 cli command "switchport access vlan 20"
action 008 end
action 009 cli command "end"

!

event manager applet detect-mac
event mat mac-address "^$oui_30"
action 001 syslog msg "detect-mac running"
action 001 cli command "enable"
action 002 cli command "config t"
action 003 cli command "interface $_mat_intf_name"
action 004 if $_mat_notification eq "add"
action 005 cli command "switchport access vlan 30"
action 008 end
action 009 cli command "end"

  • EEM Scripting
5 REPLIES
Cisco Employee

1. You'll need to add code to

1. You'll need to add code to parse the output of "show int switchport" to see if the port is a trunk.

cli command "show int $_mat_intf_name switchport | inc Operational Mode:"

regexp "trunk" "$_cli_result"

if $_regexp_result eq "1"

  exit

end

2. No, this is not possible on the event spec line.  You could build a regexp for all OUIs, and then extract a matching VLAN from a file.  You could read the file, and then extract the VLAN portion if the OUI matches the OUI portion.

New Member

Thanks Joe,

Thanks Joe,

I just want to make sure that I understand this correctly.  If I use the MAT event and parsed the interface every time a new mac was learned, would that use a lot of processing resources on the switch, depending on the amount of MAC addresses learned on the trunk?  Would that put the switch at risk of running out of resources and crashing?

Cisco Employee

It could, yes.  But there's

It could, yes.  But there's no other way to reliably filter trunk ports.  You could design an interface regexp to match ports that you know to only be access, but that would require you to know operational state up front for each switch.

New Member

As another means to protect

As another means to protect processing resources, is it possible to only run this event on an interface that changed state to up within a certain time period?  

Example:  If an interface changed state to up within the last 90 seconds, monitor MAT events?  If it's been up longer than 90 seconds, do not?

Cisco Employee

No, the event detector does

No, the event detector does not support this.  While you could react to an interface coming up and install a mat policy, I feel the timing would make this too difficult.

What you could do is have a "scheduler" policy that periodically runs and checks all interface operational states.  If they are access it installs a policy for that interface.  If it turns to trunk, it removes the policy.  The downside of this is that you will have one policy for every access port.

13
Views
0
Helpful
5
Replies
This widget could not be displayed.