how/network
One physical switch, one cable plant, but logically split into several isolated broadcast domains. The magic is in a 4-byte tag.
Picture an office: 50 wall jacks, one switch in the closet, and accounting and development have to be isolated from each other. Run a second switch and a second set of cables? No, you have VLANs.
A VLAN (Virtual LAN) is a way to logically split one physical switch into several independent broadcast domains. Hosts in VLAN 10 do not "hear" hosts in VLAN 20, even when they are plugged into adjacent ports of the same switch.
It works through 802.1Q tagging: a 4-byte tag with a VLAN ID is inserted into the Ethernet frame when it crosses a trunk port between switches, and is removed at the access port before the frame goes to the host.
Press ▶ to see how one switch serves 2 VLANs, and where the tag is added and removed.
Four hosts are connected to the switch, but they are logically separated:
The port configuration on the switch says "this port belongs to VLAN N". These are access ports: end devices connect to them, and they work without tags.
recap
What matters here:
ip link add link eth0 name eth0.10 type vlan id 10, and now
eth0.10 accepts only frames tagged with VLAN 10Related to broadcast-domain (a VLAN is a logical broadcast domain) and ethernet-frame (where the 802.1Q tag goes).