A few days ago, when I was configuring the ports of a switch and reviewing the operation of STP, I found in the CLI the command “switchport host”, when I investigated a little about the operation of this, I could confirm that it is a macro, now what is a macro?
Cisco says that “a macro is a set of commands that can be executed in the CLI. Macros do not contain new CLI commands, it is simply a group of existing CLI commands.”
So “switchport host” is used for Layer 2 configuration of a switch port; this command does three things:
- Configures the port in access mode
- Enables spanning-tree portfast
- Disables Etherchannel
It is a macro to be taken into account because of its commands; this macro can save us time in managing Cisco switches.
This command does not work on a port in route mode, i.e., for layer 3 switch ports, the port must be already in switchport mode. Otherwise, it will send a message as this “Command rejected: Gi0/1 not a switching port”.
For example, configure with “switchport host” the first ten ports of a switch:
jmcristobal# conf t
jmcristobal(config)# interface range g0/1 - 10
jmcristobal(config-if-range)# switchport host
switchport mode will be set to access
spanning-tree portfast will be enabled
channel group will be disabled
jmcristobal(config-if-range)#
To remove the command is:
jmcristobal(config-if)# no switchport host
This macro was introduced as Cisco IOS version 4.0(0)N1(1a).
Note: The command is not available in the Packet Tracer simulator (version 7.0.0.0306).