I came across this very neat feature on Cisco switches called macros. I didn’t even know they existed.
Let’s imagine the situation in which we need to apply multiple commands on an interface and do that on a regular basis. For example, we want to configure a port security feature like this:
description Some server
switchport access vlan 779
switchport mode access
switchport port-security aging time 30
switchport port-security aging type inactivity
switchport port-security mac-address sticky
Let’s pay attention on bolded lines. Those pertains to port security. Now what happens when we need to set up another port in a similar manner? We can of course do a copy/paste. Or a copy/paste with a range subcommand. But there is another way – Macro.
First we create a macro and place all commands inside:
We now have a port with some settings:
This port obviously does not have any port security settings, which is about to change:
Some lines from our macro are not listed because they are default ones. We can create different kind of macros for different uses: trunks, access, IP phones, …
Cool stuff, huh?