01-09-2012 03:44 PM
Have a interesting project that would require us to have a switchport change which VLAN it's configured to based on a specific device being plugged in. Device has a unique MAC prefix for this manufacturer and would be plugged into a Cat4500 running 12.2(54)SG1 which has EEM 3.2.0. Trying to figure out if it's possible to detect this MAC prefix and do the following IOS commands:
interface X/Y (based on which port the MAC is seen on)
switchport access vlan 500
Bonus points if there's a way to revert the interface back to another VLAN (could be statically assigned per switch) when the device is removed (link-down event?)
It looks like EEM 3.2 and higher are so new, that none of the examples I'm finding have it, and the mac-address-table information wasn't added until this release. Any suggestions or pointers to examples using this functionality would be greatly appreciated.
02-12-2012 04:23 PM
This is certainly doable. Let's say your OUI is 00:11:22. This applet should do what you want:
event manager environment my_mac_oui 00:11:22
!
event manager applet detect-mac
event mat mac-address "^$my_mac_oui"
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 500"
action 006 else
action 007 cli command "switchport access vlan 1"
action 008 end
action 009 cli command "end"
02-14-2012 02:58 AM
This functionality is similar to what would make a VMPS server? dynamically assigning vlans....
02-14-2012 06:20 AM
Similar to VMPS, yes. But with EEM you have a lot more flexibility on what is configured on the ports. This is more similar to Auto Smart Ports. In fact, ASP uses EEM on the backend.
08-07-2016 11:18 PM
Nice, thank you Joe.
I know this thread is old but I have the same issue but for a bunch of MACs. I was looking to implement this with Auto SmartPorts but it seems that Cisco is pushing to use EEM better.
What modifications should I do to the above script for a group of MACs?
What about if I have also another group of macs that I want to change complete their port configuration if the device is connected and if the device is disconnected then change it back to the previous state?
Another questions, with ASP or EEM is a best practice to have all the access ports with their config empty or pre-configured with a "default vlan" that I want to have plus other configs and then later leave the script do it's thing?
Thank you in advance.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide