14-15
Catalyst 3750-X and 3560-X Switch Software Configuration Guide
OL-21521-01
Chapter 14 Configuring Auto Smartports Macros Configuring Auto Smartports
Configuring Auto Smartports User-Defined Macros
The Cisco IOS shell provides basic scripting capabilities for configuring the user-defined Auto
Smartports macros. These macros can contain multiple lines and can include any CLI command. You
can also define variable substitution, conditionals, functions, and triggers within the macro. This
procedure is optional.
Beginning in privileged EXEC mode, follow these steps to map a user-defined event trigger to a
user-defined macro.
This example shows how to map a user-defined event trigger called media player to a user-defined
macro.
a. Connect the media player to an 802.1x- or MAB-enabled switch port.
b. On the RADIUS server, set the attribute-value pair to auto-smart-port =MP_EVENT.
c. On the switch, create the event trigger MP_EVENT, and enter the user-defined macro commands
shown below.
d. The switch recognizes the attribute-value pair=MP_EVENT response from the RADIUS server and
applies the macro associated with this event trigger.
Switch(config)# shell trigger MP_EVENT mediaplayer
Switch(config)# macro auto execute MP_EVENT {
if [[ $LINKUP -eq YES ]]; then
conf t
interface $INTERFACE
macro description $TRIGGER
switchport access vlan 1
switchport mode access
switchport port-security
switchport port-security maximum 1
switchport port-security violation restrict
switchport port-security aging time 2
switchport port-security aging type inactivity
spanning-tree portfast
spanning-tree bpduguard enable
exit
fi
if [[ $LINKUP -eq NO ]]; then
Command Purpose
Step 1 configure terminal Enter global configuration mode.
Step 2 macro auto execute event trigger
[parameter=value] {function
contents}
Specify a user-defined macro that maps to an event trigger.
{function contents} Specify a user-defined macro to associate with the
trigger. Enter the macro contents within braces. Begin the Cisco IOS shell
commands with the left brace and end the command grouping with the right
brace.
(Optional) parameter=value—Replace default values that begin with $, enter
new values in the form of name value pair separated by a space:
[<name1>=<value1> <name2>=<value2>...].
Step 3 end Return to privileged EXEC mode.
Step 4 show running-config Verify your entries.
Step 5 copy running-config startup-config (Optional) Save your entries in the configuration file.