Compared
VLAN vs subnet
A VLAN splits a switch into separate networks at the link layer, by a tag in each frame. A subnet is a block of IP addresses at the network layer. They usually go together, one subnet for each VLAN, but they are different things: the VLAN decides who hears whose frames, the subnet decides which addresses a device treats as its own network.
Side by side
| VLAN | Subnet | |
|---|---|---|
| Layer | Link (2) | Network (3) |
| Defined by | An 802.1Q tag in the frame: a VLAN ID from 1 to 4094 | An address and a prefix length: 10.0.1.0/24 |
| Set on | The switch, port by port | Every device's card, and the router's |
| Separates | Broadcast domains: who hears whose frames and broadcasts | Which addresses a device reaches directly, and which it sends to its gateway |
| Between two of them | Through a router | Through a router |
| See it with | bridge vlan | ip addr, ip route |
Each one explained
- VLAN
- Several separate networks on one switch, kept apart by a tag in each frame.
- Subnet and prefix length
- A block of addresses on one network, written as address/length: 10.0.1.0/24 holds 256 addresses.
- Trunk
- One link that carries several VLANs, each frame tagged with its VLAN, usually between switches.
- Broadcast domain
- The set of devices a broadcast reaches: one network at the link layer.
See the difference on real machines
Each lab is a small network of real Linux machines in your browser.
- VLANs: one switch, two networks that can't hear each other
- VLAN trunks: send every VLAN down one cable
- Subnet masks: why a machine on the same switch is out of reach
- Subnetting: cut one network into four to protect an exam paper
Open VLANs: one switch, two networks that can't hear each other