Switching

Switches forward frames by VLAN and learn MAC addresses as traffic flows. Spanning tree, DTP and EtherChannel negotiate between the two ends of each link, as on real Catalyst switches.

VLANs and access ports

Switch (2960)
In global configuration
vlan 10Creates VLAN 10 (vlan 10,20,30-32 creates several).
Under vlan 10
name USERSNames it.
Under interface Fa0/1
switchport mode accessMakes the port an access port (no DTP).
switchport access vlan 10Puts it in VLAN 10. If the VLAN doesn't exist yet the port is inactive until it does.
In privileged EXEC
show vlan briefEach VLAN and its access ports.
show interfaces statusEach port's status, VLAN, duplex and speed.
show mac address-tableThe MAC addresses learnt, per VLAN and port.
show interfaces Fa0/1 switchportThe port's administrative and operational mode, access and native VLAN.

Trunks and DTP

A link trunks when both ends agree: trunk with trunk, dynamic auto or dynamic desirable; or dynamic desirable with dynamic auto. Two dynamic auto ends stay access, as on a real 2960. A native VLAN mismatch logs %CDP-4-NATIVE_VLAN_MISMATCH on both switches.

Switch (2960)
Under interface Gi0/1
switchport mode trunkAlways trunk (and keep sending DTP).
switchport trunk native vlan 99Untagged frames belong to VLAN 99.
switchport trunk allowed vlan 10,20,99Carry only these VLANs (add, remove, except, all and none work too).
switchport nonegotiateStops DTP on a trunk or access port.
switchport mode dynamic desirableAsks the other end to trunk.
switchport mode trunkBack to a fixed trunk.
In privileged EXEC
show interfaces trunkEach trunk with its native VLAN, allowed VLANs and the VLANs forwarding.

switchport trunk encapsulation dot1q is accepted, as a 3560 configuration has it. Trunks are always 802.1Q: ISL isn't simulated.

IP phones: voice VLAN and PoE

An IP phone sits between the switch port and a computer: the phone's own frames are tagged with the port's voice VLAN, which the phone learns from CDP, and the computer's frames pass through untagged into the access VLAN. Without a voice VLAN (or with CDP off on the port) the phone sends untagged frames in the access VLAN, with the computer. A PoE switch powers the phone from the port; with no power the phone is dark and the port shows notconnect. Clicking a phone shows its Settings > Network Configuration screen.

Switch (2960)
Under interface Fa0/1
switchport voice vlan 20The voice VLAN, announced to the phone by CDP. The port stays an access port for the data VLAN.
power inline neverNo power on the port (auto, the default, powers a phone it detects; static reserves the power).
In privileged EXEC
show power inlineThe PoE budget (available, used, remaining) and each port's admin and operational state, watts and device.
show interfaces fa0/1 switchportThe access VLAN and the voice VLAN of the port.
show cdp neighborsPhones show as SEP followed by their MAC address, capability H P M, platform IP Phone.

Spanning tree

Every switch runs spanning tree per VLAN. The simulator elects the root bridge, root ports, designated and alternate ports from the bridge IDs, costs and port IDs, and blocks the right end. PVST+ (the default), Rapid PVST+ and MST are all there, with their own show output.

Switch (2960)
In global configuration
spanning-tree mode rapid-pvstRapid PVST+ (pvst and mst are the other modes).
spanning-tree vlan 10 priority 4096Sets the bridge priority for VLAN 10 (in steps of 4096).
spanning-tree vlan 20 root primaryMakes this switch the root for VLAN 20 (secondary for the backup root).
Under interface Gi0/1
spanning-tree cost 10The port's cost, to steer which uplink is the root port.
spanning-tree port-priority 64The port's priority, the tie-breaker between parallel links.
Under interface Fa0/1
spanning-tree portfastAn edge port: forwards at once (use it only towards hosts).
spanning-tree bpduguard enableErr-disables the port if a BPDU arrives.
In global configuration
spanning-tree portfast defaultPortFast on every access port.
spanning-tree portfast bpduguard defaultBPDU Guard on every PortFast port.
Under interface Fa0/24
spanning-tree guard rootRoot guard: the port must stay designated. Superior BPDUs (a switch that would become root) hold it blocked as root-inconsistent until they stop; logs %SPANTREE-2-ROOTGUARD_BLOCK. Use it on designated ports only.
Under interface Gi0/2
spanning-tree guard loopLoop guard: a root or alternate port that stops hearing BPDUs goes loop-inconsistent (blocked) instead of becoming designated and forwarding. It recovers when BPDUs return (none turns both guards off).
In global configuration
spanning-tree loopguard defaultLoop guard on every point-to-point port (not edge ports, not ports with root guard).
Under interface Gi0/2
spanning-tree bpdufilter enableThe port neither sends nor hears BPDUs, so both ends act as designated. On a link between switches it opens a loop, unless loop guard is on the far end.
In privileged EXEC
show spanning-treeThe root, this bridge, and each port's role, state and cost, per VLAN.
show spanning-tree vlan 10The same for one VLAN.
show spanning-tree rootThe root bridge of each VLAN and the way to it.
show spanning-tree summaryThe mode and the global features (PortFast, BPDU Guard and loop guard defaults).
show spanning-tree inconsistentportsThe ports root guard or loop guard holds blocked, per VLAN. In show spanning-tree they show BKN* and *ROOT_Inc or *LOOP_Inc.
show interfaces status err-disabledPorts err-disabled, and why.

MST

Switch (2960)
In global configuration
spanning-tree mode mstMultiple Spanning Tree.
Under spanning-tree mst configuration
name CAMPUSThe region name. Switches in one region need the same name, revision and VLAN map.
revision 1The region's revision number.
instance 1 vlan 10,20Maps VLANs to instance 1.
show pendingThe region configuration as it will be when you leave this mode.
In global configuration
spanning-tree mst 1 priority 4096This switch's priority in instance 1.
In privileged EXEC
show spanning-tree mst configurationThe region name, revision and VLAN map in use.
show spanning-tree mstEach instance's root and port roles.
In global configuration
spanning-tree mode pvstBack to PVST+.

EtherChannel

Members bundle when both ends agree (LACP active/passive, PAgP desirable/auto, or on with on) and their settings match. A member that differs is suspended. The bundle is one link for spanning tree.

Switch (2960)
Under interface range Gi0/1 - 2
channel-group 1 mode activeBundles the ports into Port-channel 1 with LACP (passive, desirable, auto and on work too).
Under interface Po1
switchport mode trunkConfigure the bundle on the port-channel; the members follow.
In global configuration
port-channel load-balance src-dst-ipHow flows are spread over the members (src-mac, dst-mac, src-dst-mac, src-ip, dst-ip, src-dst-ip).
In privileged EXEC
show etherchannel summaryEach bundle, its protocol and its members with their flags (P bundled, I stand-alone, s suspended, D down).
show etherchannel port-channelThe bundle in detail.
show etherchannel load-balanceThe load-balancing method.
show lacp neighborThe LACP partner on each member.
Under interface range Gi0/1 - 2
no channel-groupTakes the ports out of the bundle.

SVIs and inter-VLAN routing

A 2960 has one management SVI and a default gateway. A 3560 with ip routing routes between its SVIs and routed ports, and takes static routes. Routers do router-on-a-stick with subinterfaces (see Routing).

Layer 3 switch (3560)
In global configuration
ip routingTurns the switch into a router.
vlan 10The VLAN the SVI serves.
Under interface vlan 10
ip address 10.0.10.1 255.255.255.0The SVI's address: the gateway of VLAN 10. It is up once an up port is in VLAN 10.
no shutdownBrings the SVI up.
In privileged EXEC
show interfaces vlan 10The SVI's status, line protocol and address.
show ip routeThe routing table: connected SVIs and static routes.
Switch (2960)
Under interface vlan 99
ip address 10.0.99.2 255.255.255.0The management address of a Layer 2 switch.
In global configuration
ip default-gateway 10.0.99.1Where the switch sends traffic for other subnets.

SPAN and RSPAN

Switch (2960)
In global configuration
monitor session 1 source interface Fa0/1 bothCopies what Fa0/1 sends and receives (rx, tx) to the session.
monitor session 1 destination interface Fa0/10Sends the copies to Fa0/10, where an analyser listens. The port stops being a normal port.
Under vlan 900
remote-spanMakes VLAN 900 an RSPAN VLAN, to carry the copies to another switch.
In global configuration
monitor session 2 source vlan 10Monitors every port of a VLAN.
monitor session 2 destination remote vlan 900RSPAN: the copies leave in VLAN 900.
do show monitorEvery session with its sources and destination.
no monitor session allRemoves every session.