VLANs and Trunking: One Switch, Many Separate Networks
One switch, forty computers — and the guest Wi-Fi users can see the finance server. The fix is not a second switch. It is VLANs.
A VLAN (virtual local area network) carves one physical switch into several logical switches. Each VLAN is its own broadcast domain: a broadcast sent in one VLAN never reaches hosts in another. Hosts in different VLANs on the same switch can only talk to each other through a router (or a Layer 3 switch) — which is exactly where the access policy belongs.
Why segment at all
- Security: keep guests, IoT devices, and servers apart instead of trusting one flat network.
- Smaller broadcast domains: fewer hosts hear each broadcast, so less noise and less exposure.
- Organisation: group by function (staff, servers, printers, guests) rather than by which switch port happens to be free.
A typical small-office plan looks like this:
| VLAN | Name | Who lives there |
|---|---|---|
| 10 | Management | Switches, access points, hypervisors |
| 20 | Staff | Employee laptops and phones |
| 30 | Servers | File server, printers, internal apps |
| 40 | Guest | Visitor Wi-Fi, IoT devices |
Access ports: one VLAN, no tag
An access port belongs to exactly one VLAN. Frames enter and leave untagged, and the switch assigns the VLAN internally. The device plugged in — a laptop, a printer — has no idea VLANs exist.
That is the port type for end devices: one cable, one VLAN, no configuration on the device itself. One exception exam candidates meet: an access port can also carry a second, tagged voice VLAN for an IP phone alongside its single untagged data VLAN.
Trunk ports: many VLANs, one cable
A trunk port carries many VLANs between switches, or between a switch and a router, firewall, access point, or hypervisor. Each frame is tagged with its VLAN number so the receiving switch knows which VLAN it belongs to.
The tag is defined by IEEE 802.1Q. It inserts 4 bytes into the Ethernet frame, between the source MAC address and the original EtherType:
| Field | Size | What it carries |
|---|---|---|
| TPID (Tag Protocol Identifier) | 16 bits | 0x8100 for a standard 802.1Q tag — tells the receiver a tag follows (provider Q-in-Q outer tags use 0x88A8 instead) |
| PCP (Priority Code Point) | 3 bits | Class of service, 0–7, for QoS |
| DEI (Drop Eligible Indicator) | 1 bit | Marks frames that may be dropped first under congestion |
| VID (VLAN Identifier) | 12 bits | The VLAN number |
The 12-bit VID is why the usable range is VLAN 1 to 4094: 0 and 4095 are reserved. (On Cisco switches, VLANs 1002–1005 are also reserved for legacy Token Ring and FDDI.) The tag grows the largest standard Ethernet frame from 1,518 to 1,522 bytes. When a tagged frame reaches an access port, the switch strips the tag before delivering it, so the end device still receives a normal untagged frame.
The native VLAN: the one untagged exception
On a trunk, one VLAN is the native VLAN: its frames cross the trunk untagged, and any untagged frame arriving on the trunk is placed in the native VLAN. Every other VLAN on that trunk is tagged.
Two rules that catch people on the exam and in real networks:
- The native VLAN must match on both ends of the trunk. A mismatch merges two VLANs — traffic meant for one network lands in another — while every link light stays green. (Cisco switches do log a native VLAN mismatch warning via CDP, so it is not always completely silent — but the traffic still crosses.)
- Do not leave it as VLAN 1. VLAN 1 is the default VLAN and the default native VLAN on most switches. Best practice is to set the native VLAN to a dedicated, unused VLAN (for example VLAN 999) with no hosts in it, identically on both ends — or to tag everything and give the trunk no native VLAN at all. Leaving user access ports in the same VLAN as the trunk's native VLAN (typically VLAN 1) enables double-tagging VLAN hopping: an attacker on such a port sends a frame carrying two 802.1Q tags — the outer tag matching the native VLAN, the inner tag naming a target VLAN. The first switch strips the outer tag (native VLAN traffic crosses the trunk untagged) and forwards the frame; the second switch reads the surviving inner tag and delivers it into the target VLAN — no router involved. The attack is one-way (replies stay in the target VLAN), but it defeats the segmentation entirely.
A frame's journey, step by step
- A laptop on VLAN 20 sends an untagged frame to its access port.
- The switch tags the frame with VID 20 and sends it across the trunk to the second switch.
- The second switch reads the tag, finds the destination host is on one of its VLAN 20 access ports, strips the tag, and delivers a normal untagged frame.
- If the destination were in VLAN 30 instead, the frame would have to go to a router first — the switch will not forward it between VLANs on its own.
On the exam
For Network+ N10-009 and CCNA 200-301, expect scenario questions like these:
- “Hosts on the same switch must not see each other's broadcasts” → put them in separate VLANs.
- “Two switches must carry VLANs 10, 20, and 30 over one link” → configure a trunk port on both ends.
- “A frame arrives untagged on a trunk” → it belongs to the native VLAN.
- “Which VLAN IDs can be assigned?” → 1–4094.
- “How does a host in VLAN 20 reach a host in VLAN 30?” → through a router or Layer 3 switch (inter-VLAN routing).
Also remember: a VLAN is a Layer 2 concept. In practice each VLAN usually gets its own subnet, but a VLAN is not a subnet — the VLAN separates the broadcast domain, the subnet separates the IP addressing.
Practical takeaway
Before adding a second switch or a new cable run, ask whether the separation you need is logical or physical. If it is logical — guests apart from staff, servers apart from printers — a VLAN does it on the hardware you already own. Get the trunk right (tagged VLANs, matching native VLAN, nothing left on VLAN 1) and the segmentation holds.
FAQ
Is a VLAN the same as a subnet? No. A VLAN separates traffic at Layer 2; a subnet separates IP addresses at Layer 3. Each VLAN normally has its own subnet, but they are different concepts — and a host needs a router to move between VLANs even when the subnets are adjacent.
What is the difference between an access port and a trunk port? An access port carries one VLAN, untagged, for an end device. A trunk port carries many VLANs, tagged with 802.1Q, plus one untagged native VLAN — for switch-to-switch, switch-to-router, or switch-to-access-point links.
Why does the native VLAN matter if it is just one VLAN? Because it is the only VLAN whose frames cross a trunk without a tag. A mismatch between the two ends merges two networks, and leaving it on the default VLAN 1 — especially if any user ports remain in VLAN 1 — creates an opening for double-tagging VLAN hopping attacks. Set it to an unused VLAN, the same on both ends.
Ready to prove it?
Reading about VLANs and trunking is a start. CertCrack practice exams for Network+ and CCNA test you the way the real exam does — with explanations for every answer.
Try a Free Sample Quiz