Using macros on Cisco switches

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:

!
interface GigabitEthernet0/17
description Some server
switchport access vlan 779
switchport mode access
switchport nonegotiate
switchport port-security
switchport port-security aging time 30
switchport port-security aging type inactivity
switchport port-security mac-address sticky
spanning-tree portfast

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:

image

We now have a port with some settings:

image

This port obviously does not have any port security settings, which is about to change:

image

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?

Advertisements
This entry was posted in Cisco, IOS, Switching and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s