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.

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.
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 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.
| VLAN | Name | Subnet | Purpose |
|---|---|---|---|
| 10 | STAFF | 10.10.10.0/24 | Staff computers and phones |
| 20 | GUEST | 10.10.20.0/24 | Visitors, internet only |
| 30 | CCTV-IOT | 10.10.30.0/24 | Cameras and smart devices |
| 99 | MGMT | 10.10.99.0/24 | Switch and access point management |
| 999 | NATIVE-UNUSED | none | Native 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.

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:

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:

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.


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.

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

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.

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

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.


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:

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:


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:

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 accessor a hard-coded trunk, plusswitchport 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.
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
| Command | What good looks like |
|---|---|
show vlan brief | Every VLAN exists and the right ports sit in each one |
show interfaces trunk | The trunk is up, native VLAN is 999, and the allowed list shows 10,20,30,99, on both ends |
show interfaces <int> switchport | Negotiation is off and the native VLAN is 999 |
show ip interface brief | Every SVI is up/up |
show ip route connected | A connected route per VLAN |
show ip dhcp binding | Each test host has an address in its own subnet |
show spanning-tree vlan 10 | The core is root; the access switch's root port faces it |
show access-lists | The 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

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:

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:

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



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:

%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
| Symptom | Likely cause | What to check |
|---|---|---|
| Host can't reach its gateway | VLAN missing from the trunk, or access port in the wrong VLAN | show interfaces trunk, show vlan brief |
| Host can't get an address | VLAN not allowed on the trunk, or no pool for that subnet | show interfaces trunk on both ends, show ip dhcp binding |
| SVI is up/down | VLAN doesn't exist, or no active port in it | show vlan brief, show ip interface brief |
| Native VLAN mismatch warnings | Native VLAN is different on each end of the trunk | show interfaces trunk on both switches |
| Pings work one way only | An ACL or a missing return route | show access-lists, show ip route |
| Random slowness or freezes | A spanning-tree change or a loop | show 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.

