Skip to Content
Network Warrior, 2nd Edition
book

Network Warrior, 2nd Edition

by Gary A. Donahue
May 2011
Intermediate to advanced
788 pages
23h 34m
English
O'Reilly Media, Inc.
Content preview from Network Warrior, 2nd Edition

Macros

Macros, called smartport macros by Cisco, are groups of commands saved with reference names. Macros are useful when you find yourself entering the same group of commands repeatedly. For example, say you’re adding a lot of servers. Every time you add a server, you execute the same configuration commands for the switch interface to be used for that server. You could create a macro that would execute all of the commands automatically and then simply reference this macro every time you add a new server to the switch.

You create macros are created with the macro command. There are two types of macros: global and interface. An interface macro (the default type) is applied to one or more interfaces. To make a macro global, include the global keyword when creating it.

The way macros are created is a little strange, because the commands are not parsed as you enter them. As a result, you can enter invalid commands without causing errors. First, enter the macro name macroname command. Because you’re not including the global keyword, this will be an interface macro. Then, enter the commands you’d like to include in the macro, one by one. These commands are not checked for syntax. When you’re done entering commands, put an at sign (@) on a line by itself.

Here, I’ve created a macro named SetServerPorts. The commands included are spanning-tree portfast, hhhhhh (an invalid command), and description <[ Server ]>:

3750(config)#macro name SetServerPorts Enter macro commands one per line. End with ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Computer Networks, Fifth Edition

Computer Networks, Fifth Edition

David J. Wetherall, Andrew S. Tanenbaum

Publisher Resources

ISBN: 9781449307974Errata Page