June 3, 2013

Reset Cisco switch port/interface to default then apply vlan

I recently had to wrestle some switch port configurations back to default after applying to dumb settings to them.
This was for a Catalyst 3750x in a stack, although it likely applies to many cisco switches.

Reset interface (port) to default

Switch> en
Switch# conf t
Switch(config)# default interface Gi1/0/1
Switch(config)# exit

Unfortunately I could not figure out how to do this to the range like in the example below – it’s likely possible, but after the interface range command, trying to give the command default wanted another parameter, and I didn’t want to have to reset each config to default, so I just rant the above command for each interface, then did bulk range operations for applying the vlans.

 

Apply vlans to ranges or interfaces (ports)

Switch> en
Switch# conf t
Switch(config)# interface range gigabitEthernet 1/0/1-47
Switch(if-range)# switchport access vlan 100
Switch(if-range)# exit
Switch(config)# interface gigabitEthernet 1/0/48
Switch(interface)# switchport access vlan 200
Switch(interface)# exit

In that example ports 1-47 had a default vlan applied and port 48 had a management vlan applied.