Lab 1 — VLANs, Trunking & STP

Two switches, two VLANs, one trunk.

The switching every access layer runs on. Work through it in order — check steps off, copy the commands, and finish with the show commands that prove it worked.

Interactive lab — play with it

A simulated CLI for this lab. Click a switch, type the commands, and watch the show outputs change as you configure it.

A simulated CLI for this lab — click a switch, type the commands, and watch the show outputs change as you configure it. This models Lab 1’s commands only, not a real switch: unsupported commands say so instead of faking it. Type ? for help and use Tab to complete a command.

Setting up…
Topologydrag to pan · double-click a device for its console
PC-AFa0/1 · VLAN 10
PC-BFa0/3 · VLAN 20
Gi0/1 · trunk
PC-CFa0/1 · VLAN 10
PC-DFa0/3 · VLAN 20
100%
user EXEC
Lab 1 simulator — simulated IOS 15.0(2)SE. Type ? for help.
Only this lab's commands are simulated; unsupported commands say so.
Switch>

Up/down arrows recall commands. The full command list is in the walkthrough below.

Interactive lab

Lab 1 — VLANs, Trunking & STP

Two switches, four PCs, three VLANs. Build the VLANs, trunk the link, and make SW1 the spanning-tree root.

Click a device to open its console, type the real commands, and check your work when you think it’s done. The lab checks each step as you go.

Walkthrough — commands in order

Two switches, two VLANs, one trunk. Build the switching every access layer runs on: segment the traffic, carry it across a trunk, and make sure spanning tree can never loop it.

        VLAN 10 Sales — 10.1.10.0/24
  PC-A ── Fa0/1 [SW1] Gi0/1 ═════ Gi0/1 [SW2] Fa0/1 ── PC-C
  PC-B ── Fa0/3 [SW1]  trunk   trunk  [SW2] Fa0/3 ── PC-D
        VLAN 20 Engineering — 10.1.20.0/24
        Management VLAN 99 — 192.168.99.0/24

Where this shows up in the data center

This is the switching I touch every day. Top-of-rack switches carry dozens of VLANs over trunks, and before I trust a link I confirm the neighbor with LLDP and check the optics — the same verify-before-you-change-it discipline as this lab. PortFast and BPDU Guard are why a host port can never take the spanning tree down, and keeping management traffic on its own VLAN is the same segmentation thinking as the management network in the data center.

SW1(config)# hostname SW1
SW1(config)# enable secret class
SW1(config)# line console 0
SW1(config-line)# password cisco
SW1(config-line)# login
SW1(config)# line vty 0 4
SW1(config-line)# password cisco
SW1(config-line)# login
SW1(config-line)# transport input ssh
SW1(config)# service password-encryption
SW1(config)# banner motd # Authorized access only #
SW1(config)# no ip domain-lookup
SW1(config)# vlan 10
SW1(config-vlan)# name Sales
SW1(config-vlan)# vlan 20
SW1(config-vlan)# name Engineering
SW1(config-vlan)# vlan 99
SW1(config-vlan)# name Management

Do this on both switches — VLANs are local to each switch unless VTP is running, and this lab runs without VTP.

SW1(config)# interface range fa0/1 - 2
SW1(config-if-range)# switchport mode access
SW1(config-if-range)# switchport access vlan 10
SW1(config-if-range)# interface range fa0/3 - 4
SW1(config-if-range)# switchport mode access
SW1(config-if-range)# switchport access vlan 20
SW1(config)# interface gi0/1
SW1(config-if)# switchport mode trunk
SW1(config-if)# switchport trunk allowed vlan 10,20,99
SW1(config-if)# switchport trunk native vlan 99

Repeat on SW2 Gi0/1. A native VLAN mismatch throws a CDP error and leaks untagged frames into the wrong VLAN.

SW1(config)# spanning-tree vlan 10,20,99 root primary
SW2(config)# spanning-tree vlan 10,20,99 root secondary

root primary sets the priority to 24576; root secondary sets 28672. Lowest priority wins, then lowest MAC.

SW1(config)# interface range fa0/1 - 4
SW1(config-if-range)# spanning-tree portfast
SW1(config-if-range)# spanning-tree bpduguard enable

PortFast on a port facing another switch can create a temporary loop — only use it where hosts plug in.

SW1(config)# interface vlan 99
SW1(config-if)# ip address 192.168.99.11 255.255.255.0
SW1(config-if)# no shutdown
SW1(config)# ip default-gateway 192.168.99.1

Verify it worked

Don’t trust the config until a show command proves it. These are the outputs you should see — if yours differ, that’s the troubleshooting.

SW1# show vlan brief

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Gi0/2
10   Sales                            active    Fa0/1, Fa0/2
20   Engineering                      active    Fa0/3, Fa0/4
99   Management                       active
1002 fddi-default                     act/unsup
1003 token-ring-default               act/unsup

SW1# show interfaces trunk

Port        Mode             Encapsulation  Status        Native vlan
Gi0/1       on               802.1q         trunking      99

Port        Vlans allowed on trunk
Gi0/1       10,20,99

Port        Vlans allowed and active in management domain
Gi0/1       10,20,99

SW1# show spanning-tree vlan 10

VLAN0010
  Spanning tree enabled protocol ieee
  Root ID    Priority    24586
             Address     0001.42aa.0001
             This bridge is the root
  Bridge ID  Priority    24586
             Address     0001.42aa.0001

Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1            Desg FWD 19        128.1    Edge P2p
Fa0/2            Desg FWD 19        128.2    Edge P2p
Gi0/1            Desg FWD 4         128.25   P2p

Check yourself

Three questions from the exam angle. Tap to reveal the answer — say it out loud first.

Q1. Two switches are trunked together with different native VLANs. What breaks?

Q2. Which switch becomes the spanning-tree root, and why?

Q3. What does PortFast skip — and why pair it with BPDU Guard?

Next labs:

Keep going: Lab 2 — OSPF stands up routing between three routers, and Lab 3 — ACLs & NAT locks down an edge router. Or back to the labs hub.