VLAN (Virtual Local Area Network)
What it is for
By default every port on a switch shares one broadcast domain -- a broadcast from anyone reaches everyone.
A VLAN inserts a 4-byte tag into the frame, carving one physical switch into several logical ones that cannot reach each other. A broadcast domain is now one VLAN.
When the tag exists
★★★ The key point about VLANs:
· Access port: the frame is untagged -- the host has no idea VLANs exist;
· Entering the switch: a tag is added based on which VLAN the port belongs to;
· On the trunk: it travels tagged, so the far end knows which VLAN it belongs to;
· Leaving an access port: the tag is stripped before the host sees it.
★★ So a capture on the host side shows no tag; only a trunk capture does.
★ Common misconceptions
★★★ "Just add a cable between two VLANs" -- no. Crossing VLANs requires a layer-3 device (a router or L3 switch), because they are different broadcast domains and usually different subnets.
★★ "You can have as many VLANs as you like" -- the VID is only 12 bits, so 1-4094 are usable. Carriers ran out, which is why QinQ exists.
★★ "Every frame on a trunk is tagged" -- frames in the native VLAN are not. Mismatched native VLANs at the two ends leak traffic into the wrong VLAN.