VLANs and trunks: one building, separate floors
▶ Start the interactive lesson
Ticket #160, from Security: "Visitors on guest Wi-Fi can see the finance file server!" Everyone's on the same flat network. Maya: "We need floors with locked doors. Same building, same switches, but separate networks. VLANs."
The problem with one big switch
Every device on a switch is in the same broadcast domain: when one shouts (a broadcast), everyone hears it. Sales, HR and guests all on one network means no separation, more noise and more risk.
A VLAN is a virtual switch inside the switch
A VLAN (virtual LAN) splits one physical switch into several separate networks. Ports in VLAN 10 only talk to VLAN 10, and ports in VLAN 20 only to VLAN 20, as if they were different switches.
Access ports: one VLAN per port
A port that connects a PC or printer is an access port in exactly one VLAN. The PC has no idea VLANs exist: the switch handles it.
Trunks: many VLANs on one cable
Between switches (or to a router) you don't want one cable per VLAN. A trunk carries all VLANs on one link by adding a small 802.1Q tag to each frame that says which VLAN it belongs to. The other end reads the tag and removes it.
Talking between VLANs needs a router
VLANs are separate networks, so traffic between them must be routed, exactly like between any two networks. Each VLAN gets a gateway.
Key points
- A VLAN splits one physical switch into several separate networks (broadcast domains). Usually 1 VLAN = 1 subnet.
- Access port: belongs to one VLAN. Frames are untagged and the PC never knows. Trunk port: carries many VLANs between switches or to a router, adding a 4-byte 802.1Q tag with the VLAN ID. The native VLAN travels untagged.
- Getting between VLANs needs routing: router-on-a-stick (subinterfaces) or a Layer 3 switch with SVIs.