Get a quote
CCNP EnterpriseIntermediate8 November 202614 min read

VLANs in practice: trunks, inter-VLAN routing and the mistakes that break them

A two-switch VLAN lab built the way a small business would run it: hardened trunk and access ports, SVI routing, DHCP, a guest ACL, spanning-tree roots, and a fault I broke on purpose and fixed, with the real CLI output.

CCNPVLANTrunkingACLSpanning TreeLab

VLANs look simple on a diagram. In a real network, most outages on switched networks come from small mistakes around them: a VLAN missing from a trunk, a native VLAN mismatch, or a guest network that can still reach the office. This lab builds a small, realistic VLAN design on two switches in Cisco Modeling Labs, proves each piece with the CLI, and then breaks it on purpose.

TipNew to VLANs? Start with the beginner version of this lab, which explains every term. This post assumes you know what a VLAN, a trunk and an SVI are, and goes into why each setting is there.

What this lab covers

  • Designing VLANs and an addressing plan for a small business
  • Hardened access ports and a pruned trunk with an unused native VLAN
  • Inter-VLAN routing with SVIs on a layer 3 switch
  • DHCP for every VLAN
  • Isolating the guest network with an extended ACL
  • Spanning-tree root placement
  • A fault I introduced on purpose, how it showed up, and how to find it
The lab in Cisco Modeling Labs: CORE (layer 3 switch) and ACCESS joined by one trunk, with a computer in each VLAN.
The lab in Cisco Modeling Labs: CORE (layer 3 switch) and ACCESS joined by one trunk, with a computer in each VLAN.

The lab uses two IOL-L2 switch nodes, CORE and ACCESS, and three Linux hosts. The trunk is Et0/0 on both switches. The hosts sit on ACCESS Et0/1 (staff), Et0/2 (guest) and Et0/3 (CCTV).

The design

Every VLAN gets its own /24, and the gateway is always the .1 address.

VLANNameSubnetPurpose
10STAFF10.10.10.0/24Staff computers and phones
20GUEST10.10.20.0/24Visitors, internet only
30CCTV-IOT10.10.30.0/24Cameras and smart devices
99MGMT10.10.99.0/24Switch and access point management
999NATIVE-UNUSEDnoneNative VLAN on trunks, nothing lives here

Three design choices are worth explaining:

  • An unused native VLAN. Untagged traffic on a trunk goes into the native VLAN. If that is VLAN 1 (the default) or a VLAN with real devices in it, you open the door to double-tagging attacks and to confusing mismatches. A dedicated, empty VLAN avoids both.
  • A pruned allowed list. A trunk should carry only the VLANs that need to cross it.
  • No DTP. Trunking is configured by hand and negotiation is switched off, so a rogue device can't negotiate its way onto a trunk.

1create the VLANs

Run this on both switches. Each switch keeps its own VLAN database.

vtp mode transparent
!
vlan 10
 name STAFF
vlan 20
 name GUEST
vlan 30
 name CCTV-IOT
vlan 99
 name MGMT
vlan 999
 name NATIVE-UNUSED

VTP is set to transparent so a mistake on one switch can't overwrite the VLAN database on the other. On platforms running VTPv3, vtp mode off does the same job.

show vlan brief on CORE: the four working VLANs exist and are active.
show vlan brief on CORE: the four working VLANs exist and are active.

CORE lists no ports against VLANs 10 to 99. That is expected: its only active port is the trunk, which is not an access port.

2the trunk, configured on both ends

interface Ethernet0/0
 switchport trunk encapsulation dot1q
 switchport mode trunk
 switchport trunk native vlan 999
 switchport trunk allowed vlan 10,20,30,99
 switchport nonegotiate

The encapsulation command is only needed on switches that support both 802.1Q and ISL. Newer platforms accept 802.1Q only and reject it, so skip that line if you get an error.

show interfaces trunk gives the short version, but show interfaces <int> switchport shows the security-relevant details in one place:

show interfaces Ethernet0/0 switchport on CORE: negotiation off, native VLAN 999, and only VLANs 10, 20, 30 and 99 trunked.
show interfaces Ethernet0/0 switchport on CORE: negotiation off, native VLAN 999, and only VLANs 10, 20, 30 and 99 trunked.

Check three lines: Negotiation of Trunking: Off (no DTP), Trunking Native Mode VLAN: 999 (NATIVE-UNUSED), and Trunking VLANs Enabled: 10,20,30,99. Then check the other end, because a trunk is only as good as both sides agreeing:

show interfaces trunk on ACCESS: trunking, native VLAN 999, and the same allowed list as CORE.
show interfaces trunk on ACCESS: trunking, native VLAN 999, and the same allowed list as CORE.

Both ends show native VLAN 999 and the same allowed list. If they differ, you get the mismatch I broke later in this post.

3harden the access ports

interface range Ethernet0/1 - 3
 switchport mode access
 switchport nonegotiate
 spanning-tree portfast
 spanning-tree bpduguard enable
!
interface Ethernet0/1
 switchport access vlan 10
interface Ethernet0/2
 switchport access vlan 20
interface Ethernet0/3
 switchport access vlan 30

PortFast brings end-device ports up straight away. BPDU guard shuts the port if someone plugs in a switch, which protects the spanning tree. switchport mode access plus nonegotiate means the port can never become a trunk.

The running configuration of ACCESS Et0/1: access mode, no negotiation, PortFast and BPDU guard.
The running configuration of ACCESS Et0/1: access mode, no negotiation, PortFast and BPDU guard.
show vlan brief on ACCESS: each host port sits in its own VLAN.
show vlan brief on ACCESS: each host port sits in its own VLAN.

4inter-VLAN routing with SVIs

ip routing
!
interface Vlan10
 ip address 10.10.10.1 255.255.255.0
 no shutdown
interface Vlan20
 ip address 10.10.20.1 255.255.255.0
 no shutdown
interface Vlan30
 ip address 10.10.30.1 255.255.255.0
 no shutdown
interface Vlan99
 ip address 10.10.99.1 255.255.255.0
 no shutdown

An SVI only comes up when its VLAN exists and at least one port in that VLAN is up (an access port or a trunk carrying it). If an SVI shows up/down, that is the first place to look.

show ip interface brief on CORE: all four SVIs are up/up.
show ip interface brief on CORE: all four SVIs are up/up.

With ip routing on, the routing table is built from those interfaces, so there is nothing else to configure for traffic between the VLANs:

show ip route connected on CORE: a connected route and a local route for each of the four VLAN interfaces.
show ip route connected on CORE: a connected route and a local route for each of the four VLAN interfaces.

Router-on-a-stick uses sub-interfaces on one router link instead (encapsulation dot1Q 10 on g0/0.10, and so on). It works well for small sites, but a layer 3 switch routes between VLANs in hardware and doesn't squeeze all inter-VLAN traffic through a single link.

5DHCP for each VLAN

ip dhcp excluded-address 10.10.10.1 10.10.10.20
ip dhcp excluded-address 10.10.20.1 10.10.20.20
ip dhcp excluded-address 10.10.30.1 10.10.30.20
!
ip dhcp pool STAFF
 network 10.10.10.0 255.255.255.0
 default-router 10.10.10.1
 dns-server 1.1.1.1
ip dhcp pool GUEST
 network 10.10.20.0 255.255.255.0
 default-router 10.10.20.1
 dns-server 1.1.1.1
ip dhcp pool CCTV-IOT
 network 10.10.30.0 255.255.255.0
 default-router 10.10.30.1
 dns-server 1.1.1.1

If the DHCP server is somewhere else, use ip helper-address <server> on each SVI instead.

show ip dhcp binding on CORE: one lease in each VLAN, each on its own interface.
show ip dhcp binding on CORE: one lease in each VLAN, each on its own interface.

The binding table also tells you which SVI served the request, which is a quick way to confirm a host is really in the VLAN you think it is.

6isolate the guest network

Guests should reach the internet and nothing inside. An extended access list on the guest SVI does that:

ip access-list extended GUEST-IN
 permit udp any eq bootpc any eq bootps
 deny ip 10.10.20.0 0.0.0.255 10.10.0.0 0.0.255.255
 permit ip any any
!
interface Vlan20
 ip access-group GUEST-IN in
The ACL applied inbound on Vlan20.
The ACL applied inbound on Vlan20.

Order matters, because the first matching line wins. The first line lets guests ask for a DHCP address (their request has no address yet, so it would otherwise be caught by the deny). The second blocks anything from the guest subnet going to the internal 10.10.x.x ranges, and the last line lets everything else, which means the internet, through. The guests' DNS server is public (1.1.1.1), so name lookups still work.

Direction matters too. The list is applied in on the guest SVI, so it filters traffic as it arrives from the guests, before routing. Applied out on another SVI it would stop replies too and behave differently.

Because the deny covers the whole 10.10.0.0/16 range, guests can't even ping their own gateway. That is intended in this design; add a narrow permit above the deny if you want it.

From GUEST-PC: a DHCP lease is obtained, then a ping to a staff address gets no replies.
From GUEST-PC: a DHCP lease is obtained, then a ping to a staff address gets no replies.
show access-lists: the deny rule has 10 matches, one for each ping the guest sent.
show access-lists: the deny rule has 10 matches, one for each ping the guest sent.

The counters are the proof. This lab has no internet link, so the matches on the deny line are the evidence that the block is working, not just the failed ping. Staff traffic is unaffected:

From STAFF-PC: a ping to the CCTV gateway on another VLAN gets all replies.
From STAFF-PC: a ping to the CCTV gateway on another VLAN gets all replies.

7spanning-tree roots

! on CORE
spanning-tree mode rapid-pvst
spanning-tree vlan 1,10,20,30,99 root primary
!
! on ACCESS
spanning-tree mode rapid-pvst

Rapid PVST+ converges in seconds. Setting the core as the root bridge keeps the layout predictable, instead of letting the lowest MAC address win. Check it from both sides:

CORE for VLAN 10: this bridge is the root.
CORE for VLAN 10: this bridge is the root.
ACCESS for VLAN 10: the root is on the other switch, and Et0/0 is the root port.
ACCESS for VLAN 10: the root is on the other switch, and Et0/0 is the root port.

On ACCESS the root ID points at CORE's priority and MAC address, and Et0/0 is the root port. On CORE the summary confirms it is the root for every VLAN in use:

show spanning-tree summary on CORE: root bridge for VLANs 1, 10, 20, 30 and 99.
show spanning-tree summary on CORE: root bridge for VLANs 1, 10, 20, 30 and 99.

Why VLAN hopping matters

  • Switch spoofing. An attacker's device negotiates a trunk using DTP and then sees every VLAN. The fix is switchport mode access or a hard-coded trunk, plus switchport nonegotiate. Both are in the screenshots above.
  • Double tagging. A crafted frame carries two tags, and the switch strips the outer one when it matches the native VLAN. The fix is a native VLAN that nothing uses, so the trick has nowhere to land.
In the real worldOn a production switch you would also shut down unused ports and park them in the empty VLAN 999, for example interface range Ethernet1/0 - 3, switchport access vlan 999, shutdown. This lab only has the four ports it uses, so I could not show that step here.

Checking it works

CommandWhat good looks like
show vlan briefEvery VLAN exists and the right ports sit in each one
show interfaces trunkThe trunk is up, native VLAN is 999, and the allowed list shows 10,20,30,99, on both ends
show interfaces <int> switchportNegotiation is off and the native VLAN is 999
show ip interface briefEvery SVI is up/up
show ip route connectedA connected route per VLAN
show ip dhcp bindingEach test host has an address in its own subnet
show spanning-tree vlan 10The core is root; the access switch's root port faces it
show access-listsThe counters on GUEST-IN go up when a guest host tries to reach inside

Then test from the hosts: a staff PC should ping the CCTV gateway, and a guest host should not reach a staff address.

Breaking it on purpose

A network you have only ever seen working is a network you cannot fix. So I broke this one. On ACCESS I removed VLAN 20 from the trunk's allowed list:

interface Ethernet0/0
 switchport trunk allowed vlan remove 20
Removing VLAN 20 from the trunk on ACCESS.
Removing VLAN 20 from the trunk on ACCESS.

Nothing complains. There is no error and the trunk stays up. The first symptom is a guest host that cannot get an address. From GUEST-PC, udhcpc -i eth0 -n sends discover after discover and gets no answer:

GUEST-PC keeps broadcasting a discover, gets no offer, and gives up with no lease.
GUEST-PC keeps broadcasting a discover, gets no offer, and gives up with no lease.

Because the guest's DHCP discover never crosses the trunk, CORE never sees it. So show ip dhcp binding on CORE would show nothing new, and the fault is not on the DHCP server at all. Working from the host towards the core, the next check is the trunk:

show interfaces trunk on ACCESS: VLAN 20 is missing from the allowed list.
show interfaces trunk on ACCESS: VLAN 20 is missing from the allowed list.

There it is: 10,30,99. VLAN 20 is no longer allowed, active or forwarding on the trunk. The fix is one command:

interface Ethernet0/0
 switchport trunk allowed vlan add 20
Adding VLAN 20 back to the trunk.
Adding VLAN 20 back to the trunk.
show interfaces trunk: the allowed list is 10,20,30,99 again.
show interfaces trunk: the allowed list is 10,20,30,99 again.
GUEST-PC asks again and is given 10.10.20.21 by 10.10.20.1.
GUEST-PC asks again and is given 10.10.20.21 by 10.10.20.1.

The lesson is the order of the investigation. A host with no address points at DHCP, but if the request never reaches the server, the problem is between the host and the server: the access port's VLAN, then the trunk. Use add and remove on the allowed list, not a fresh allowed vlan list. Typing a new list replaces the old one, and forgetting a VLAN in it is how this exact fault is created in real networks.

A native VLAN mismatch

The other fault came up by itself while I was building the trunk. CORE started printing this warning again and again:

CORE complaining about a native VLAN mismatch with ACCESS.
CORE complaining about a native VLAN mismatch with ACCESS.

%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on Ethernet0/0 (999), with ACCESS Ethernet0/0 (1)

CORE's end of the cable was set to native VLAN 999, but ACCESS still had the default, VLAN 1. CDP noticed that the two ends of the trunk disagree. Left alone, untagged frames on one side land in a different VLAN from the other side. The fix is to apply the same native VLAN on both ends, which gives the matching output in Step 2.

When it goes wrong

SymptomLikely causeWhat to check
Host can't reach its gatewayVLAN missing from the trunk, or access port in the wrong VLANshow interfaces trunk, show vlan brief
Host can't get an addressVLAN not allowed on the trunk, or no pool for that subnetshow interfaces trunk on both ends, show ip dhcp binding
SVI is up/downVLAN doesn't exist, or no active port in itshow vlan brief, show ip interface brief
Native VLAN mismatch warningsNative VLAN is different on each end of the trunkshow interfaces trunk on both switches
Pings work one way onlyAn ACL or a missing return routeshow access-lists, show ip route
Random slowness or freezesA spanning-tree change or a loopshow spanning-tree detail, topology change counters

What I would add next

This lab covers the foundation. For a production small business, the next layers are DHCP snooping and dynamic ARP inspection on the access ports, a firewall between the guest VLAN and the internet instead of an ACL alone, and port security or 802.1X for staff ports. None of those are in this lab, and I have not tested them here, so I am not claiming results for them.

Want this done properly for your business?

If you'd like your network split into safe, separate parts, with the rules written down and the settings backed up, that's what I do. See my services, or message me for a quote.

Need a hand with your network?

Message me with the problem and some times that suit you. You get the price in writing before I start.