Wednesday, January 04, 2012

Cisco Switch Smartport configuration via CLI

After barking up the wrong troubleshooting tree for some time, I ran into a situation where a customer needed a UC540 switchport configured for trunking to a Linksys switch hiding in a ceiling.  Due to VPN network configurations out of my control, I was unable to use Cisco CCA to modify it.  Knowing using the CLI is somewhat of a no-no on UC540s, I wanted to apply the Smartport configurations as if they had been done so via CCA, verses just reconfiguring as if it was any other manageable switch.

You can display the macros used (I think) by CCA as follows:

! To show a short list of available macros, run:
!
UC540#show parser macro brief
!
! This returns:
!
default interface: cisco-desktop
default interface: cisco-phone
default interface: cisco-switch
default interface: cisco-router
default interface: cisco-wireless

! To show the macro details and variables that need to be set, run:
!
UC540#show parser macro
!
! This returns
!
Total number of macros = 5
--------------------------------------------------------------
Macro name : cisco-desktop
Macro type : default interface
# macro keywords $access_vlan
# Basic interface - Enable data VLAN only
# Recommended value for access vlan should not be 1
switchport access vlan $access_vlan
switchport mode access
# Configure port as an edge network port
spanning-tree portfast
--------------------------------------------------------------
Macro name : cisco-phone
Macro type : default interface
# Cisco IP phone + desktop template
# macro keywords $access_vlan $voice_vlan
# VoIP enabled interface - Enable data VLAN
# and voice VLAN
# Recommended value for access vlan should not be 1
switchport access vlan $access_vlan
switchport mode access
# Update the Voice VLAN value which should be
# different from data VLAN
# Recommended value for voice vlan should not be 1
switchport voice vlan $voice_vlan
# Configure port as an edge network port
spanning-tree portfast
--------------------------------------------------------------
Macro name : cisco-switch
Macro type : default interface
# macro keywords $native_vlan
# Access Uplink to Distribution
# Do not apply to EtherChannel/Port Group
switchport trunk encapsulation dot1q
# Define unique Native VLAN on trunk ports
# Recommended value for native vlan should not be 1
switchport trunk native vlan $native_vlan
# Update the allowed VLAN range such that it
# includes data, voice and native VLANs
switchport trunk allowed vlan ALL
# Hardcode trunk
switchport mode trunk
--------------------------------------------------------------
Macro name : cisco-router
Macro type : default interface
# macro keywords $native_vlan
# Access Uplink to Distribution
switchport trunk encapsulation dot1q
# Define unique Native VLAN on trunk ports
# Recommended value for native vlan should not be 1
switchport trunk native vlan $native_vlan
# Update the allowed VLAN range such that it
# includes data, voice and native VLANs
switchport trunk allowed vlan ALL
# Hardcode trunk
switchport mode trunk
# Ensure fast access to the network when enabling the interface.
# Ensure that switch devices cannot become active on the interface.
spanning-tree portfast
--------------------------------------------------------------
Macro name : cisco-wireless
Macro type : default interface
# macro keywords $native_vlan
# Access Uplink to Distribution
switchport trunk encapsulation dot1q
# Define unique Native VLAN on trunk ports
# Recommended native vlan should NOT be 1
switchport trunk native vlan $native_vlan
# Update the allowed VLAN range such that it
# includes data, voice and native VLANs
switchport trunk allowed vlan ALL
# Hardcode trunk to speed up convergence
switchport mode trunk
# Ensure that switch devices cannot become active on the interface.
spanning-tree portfast
--------------------------------------------------------------

! To apply a macro, make note of the macro name and keyword
!
! For example, the cisco-switch macro has a $native_vlan keyword
!
! Then, after removing commands already specific to the port, run (assuming configuring for a switch with native VLAN 1):
!
UC540(config)#int f0/1/2
UC540(config-if)#macro apply cisco-switch $native_vlan 1
UC540(config-if)#macro description cisco-switch

The macros don't do anything I wouldn't normally do, but at least keeps your CCA and CLI configurations consistent.

Pretty cool.

No comments:

Post a Comment