cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
929
Views
0
Helpful
1
Replies

SG300 and Smartports

Dirk Dittert
Level 1
Level 1

I'm using an SG300 as an access switch to connect client machines to my network. I do have a bunch of wireless access points that need to be connected as well. It is my understanding that smart ports can be used to ensure that the configuration is consistent for those ports.

I'd like to create a macro that sets up proper VLAN membership for those ports, allows tagged frames, and some more. Smartport > Smartport Type Settings already has a number of predefined macros but I haven't found a way to define my own custom macros. There is no "add macro" button on that page and when I edit one of the predefined macros, the radio button for custom is always greyed out. 

Can somebody point me in the right direction on how to use this feature and what I might be doing wrong here?

Thanks!

1 Reply 1

Roman Poluckhin
Level 1
Level 1

Hi, Dirk.

Use this command, to create a macro:

32.1 macro name
Use the macro name Global Configuration mode command to define a macro.
There are two types of macros that can be defined:
• Global macros define a group of CLI commands that can be run at any time.
• Smartport macros are associated with Smartport types. For each
Smartport macro there must be an anti macro (a macro whose name is
concatenated with no_). The anti macro reverses the action of the macro.
If a macro with this name already exists, it overrides the previously-defined one.
Use the no form of this command to delete the macro definition.
Syntax
macro name macro-name
no macro name [macro-name]
Parameters
• macro-name—Name of the macro. Macro names are case sensitive.
Default Configuration
N/A
Command Mode
Global Configuration mode
User Guidelines
A macro is a script that contains CLI commands and is assigned a name by the
user. It can contain up to 3000 characters and 200 lines.
Keywords
Macro Commands
OL-32830-01 Command Line Interface Reference Guide 686
32
Macros may contain keywords (parameters). The following describes these
keywords:
• A macro can contain up to three keywords.
• All matching occurrences of the keyword are replaced by the
corresponding value specified in the macro command.
• Keyword matching is case-sensitive
• Applying a macro with keywords does not change the state of the original
macro definition.
User Feedback
The behavior of a macro command requiring user feedback is the same as if the
command is entered from terminal: it sends its prompt to the terminal and accepts
the user reply.
Creating a Macro
Use the following guidelines to create a macro:
• Use macro name to create the macro with the specified name.
• Enter one macro command per line.
• Use the @ character to end the macro.
• Use the # character at the beginning of a line to enter a comment in the
macro.
In addition, # is used to identify certain preprocessor commands that can
only be used within a macro. There are two possible preprocessor
commands:
- #macro key description - Each macro can be configured with up to 3
keyword/description pairs. The keywords and descriptions are
displayed in the GUI pages when the macro is displayed.
The syntax for this preprocessor command is as follows:
#macro key description $keyword1 description1 $keyword2 description2
$keyword3 description3
A keyword must be prefixed with '$'.
- #macro keywords - This instruction enables the device to display the
keywords as part of the CLI help. It accepts up to 3 keywords. The
command creates a CLI help string with the keywords for the macro. The
Macro Commands
687 OL-32830-01 Command Line Interface Reference Guide
32
help string will be displayed if help on the macro is requested from the
macro and macro global commands. The GUI also uses the keywords
specified in the command as the parameter names for the macro. See
Example 2 and 3 below for a description of how this command is used in
the CLI.
The syntax for this preprocessor command is as follows:
#macro keywords $keyword1 $keyword2 $keyword3
where $keywordn is the name of the keyword.
Editing a Macro
Macros cannot be edited. Modify a macro by creating a new macro with the same
name as the existing macro. The newer macro overwrites the existing macro.
The exceptions to this are the built-in macros and corresponding anti-macros for
the Smartport feature. You cannot override a Smartport macro. To change a
Smartport macro, create a new macro (my_macro) and an anti macro
(no_my_macro) and associate it with the Smartport type using the macro auto user
smartport macro command.
Scope of Macro
It is important to consider the scope of any user-defined macro. Because of the
potential hazards of applying unintended configurations, do not change
configuration modes within the macro by using commands such as exit, end, or
interface interface-id. With a few exceptions, there are other ways of executing
macros in the various configuration modes. Macros may be executed in Privileged
Exec mode, Global Configuration mode, and Interface Configuration mode (when
the interface is NOT a VLAN.)
Examples
Example 1 -The following example shows how to create a macro that configures
the duplex mode of a port.
switchxxxxxx(config)# macro name dup
Enter macro commands one per line. End with the character ‘@’.
#macro description dup
duplex full
negotiation
@
Macro Commands
OL-32830-01 Command Line Interface Reference Guide 688
32
Example 2 -The following example shows how to create a macro with the
parameters: DUPLEX and SPEED. When the macro is run, the values of DUPLEX
and SPEED must be provided by the user. The #macro keywords command
enables the user to receive help for the macro as shown in Example 3.
switchxxxxxx(config)# macro name duplex
Enter macro commands one per line. End with the character ‘@’.
duplex $DUPLEX
no negotiation
speed $SPEED
#macro keywords $DUPLEX $SPEED
@
Example 3 -The following example shows how to display the keywords using the
help character ? (as defined by the #macro keywords command above) and then
run the macro on the port. The #macro keywords command entered in the macro
definition enables the user to receive help for the macro, as shown after the words
e.g. below.
switchxxxxxx(config)# interface gi11
switchxxxxxx(config-if)# macro apply duplex ?
WORD <1-32> Keyword to replace with value e.g. $DUPLEX, $SPEED
<cr>
switchxxxxxx(config-if)# macro apply duplex $DUPLEX ?
WORD<1-32> First parameter value
<cr>
switchxxxxxx(config-if)# macro apply duplex $DUPLEX full $SPEED ?
WORD<1-32> Second parameter value
switchxxxxxx(config-if)# macro apply duplex $DUPLEX full $SPEED 100

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Switch products supported in this community
Cisco Business Product Family
  • CBS110
  • CBS220
  • CBS250
  • CBS350
Cisco Switching Product Family
  • 110
  • 200
  • 220
  • 250
  • 300
  • 350
  • 350X
  • 550X