VLAN concepts and access ports
One switch, two networks that cannot hear each other. How a VLAN splits a switch, what an access port does to every frame, and why crossing between VLANs takes a router.
Upcoming practical lab
VLANs
After 2 topics: this one and the next · First lab on the topic · One switch and three PCs
View topology, objectives and expected results
One switch, three desks. PC1 and PC2 belong to sales, PC3 to engineering, and the two teams must not see each other's traffic. Buying a second switch would do it. A VLAN does the same thing inside the one you have.
What you will do
- Name the switch and address the three PCs on one network
- Read which VLAN every port starts in
- Create two VLANs and put each port in its VLAN
- Test the wall from PC1, then read the switch back
- Move PC3 to sales without touching either PC
- Give desk 1 a voice VLAN for an IP phone, then save
What it looks like when it works
PC1 still reaches PC2 and no longer reaches PC3, although nothing about PC3's address changed. Then PC3 joins sales and is reachable again, and port 1 carries data in VLAN 10 and calls in VLAN 30.
Open the free labNo account needed. The bench opens on this lab. It needs a computer: phones and tablets are not supported.
8:50 a.m. · A boarding pass on the office printer
Monday, the first day of month one. Noor walks over holding a boarding pass: somebody's 14:05 flight to Lisbon, still warm from the office printer.
"Unless the printer's flying to Lisbon, somebody at the guest kiosk printed this on it. Why can the kiosk see my printer?"
"It can't," says Maya. "The kiosk's on a different VLAN." The printer, as ever, says nothing.
Maya is half right. By lunch, you'll know which half.
8:55 a.m. · Who hears Maya?
Before anyone looks into the boarding pass, Maya sits down to print something of her own. Here is the office as LAB-SW1 sees it. One thing has changed since Thursday of week one: the next day, R1 got a second cable into LAB-SW1, on Fa0/8, so the kiosk could reach the internet. And the window desk, Fa0/5, is still shut down, as Maya left it on Thursday, until the new starter arrives.
Maya's laptop needs the printer's MAC address, so it sends an ARP broadcast (topic 01.7): one frame, addressed to ffff.ffff.ffff. Make a call.
Watch the morning in six steps →
Each step sends a frame through the model of this office. Open LAB-SW1 to see its table grow, one VLAN at a time.
Eli got a copy, a hallway away, and so did R1. The kiosk got nothing: it's plugged into the same switch as everyone else, three ports from Noor, and LAB-SW1 didn't send it a single copy. Try it yourself: pick who asks everyone, and watch where the copies go.
Maya's broadcast, in VLAN 10: 4 copies, one of them to R1. Every other port gets none.
Here's the idea underneath. From one angle, a LAN is everything in one location: the user devices, servers, switches, routers, cables and wireless access points. VLANs need a narrower definition. A broadcast domain is a set of devices where, when any one of them sends a broadcast, all the others get a copy. In that narrow sense, a LAN and a broadcast domain are basically the same thing. Using only default settings, a switch treats all its ports as one broadcast domain.
A VLAN, a virtual LAN, is a broadcast domain the switch makes by configuration: some of its ports go in one, some in another, and the switch treats each group as completely separate. It never forwards a frame from a port in one VLAN out of a port in another. LAB-SW1 has two: VLAN 10, the office, and VLAN 20, the guest kiosk. One switch, doing the job that would otherwise take two.
The kiosk is plugged into the same box as Noor, and has never heard one of her broadcasts. The box has more than one broadcast domain inside it.
Don't take "inside" too far. A VLAN is a group of ports that the switch forwards frames among, not a room with walls, and not a lock. You'll see what it doesn't stop before lunch.
One more thing the board shows: R1 appears in both lanes, because it has a cable in each.
A switch with default settings is one broadcast domain: a broadcast that comes in one port goes out all the others. That's because every port starts in the same VLAN, VLAN 1, called the default VLAN. So before VLANs, two broadcast domains meant two physical switches, one per group. A VLAN lets a single switch keep the two groups apart by configuration. And a switch needs no configuration at all to forward frames (topic 02.5), until you want more than one VLAN.
9:00 a.m. · Sam's desk
At nine the new starter arrives: Sam, at the window desk. Maya types no shutdown on Fa0/5, the command she tried on it on Thursday, and it comes up. Sam asks the question everyone else is too polite to ask: "Which network am I on?"
Fa0/5 is an access port (also called an access interface, or a static access interface): a port for an end device, configured to be in one VLAN only, and not to trunk. (A trunk carries several VLANs between switches; that's topic 03.1.3.) LAB-SW1 treats every frame that arrives on Fa0/5 as a VLAN 10 frame, because Fa0/5 is in VLAN 10, and what it sends to Sam goes out as an ordinary frame too.
Sam doesn't have to write "VLAN 10" on every frame. Fa0/5 is already assigned to that desk's VLAN.
So Sam's VLAN was decided before Sam arrived, by whoever set up Fa0/5. Try it on the board: set Sam's desk to VLAN 20, and pick Sam. The cable hasn't moved, and Sam is in the kiosk's broadcast domain.
"So if I'd sat at the kiosk, I'd be a guest?" On that port, yes. Maya would rather Sam didn't.
One exception, for later: a desk phone's port also carries a second VLAN for the phone's own traffic, the voice VLAN (topic 03.1.5). An ordinary access port, like Sam's, has one VLAN.
9:15 a.m. · Three frames
Maya shows Sam how LAB-SW1 decides where a frame goes. It's the same two moves as week one (topic 02.5): learn from the source, look up the destination. The VLAN only draws a boundary around them. Three frames:
That's why the MAC address table has a Vlan column: every row belongs to one VLAN. A switch that forwards frames this way, by MAC address and within a VLAN, is a Layer 2 switch. LAB-SW1 is one.
9:30 a.m. · Eli is in, the kiosk is out
Sam, looking down the hallway: "Is Eli on our network, or the kiosk's?"
Eli is in. The hallway cable is in VLAN 10 at both ends, so LAB-SW1's Gi0/1 and SW2's Gi0/2 are VLAN 10 ports, neither of them a trunk, and Maya's broadcast reached Eli at 8:55. The kiosk, three ports from Maya, is out. VLANs group ports by configuration, not by where anyone sits, so a design can group people by the team they work with rather than by where their desk is.
The hallway cable carries exactly one VLAN. That's one way to stretch VLANs across switches: a separate link between the switches for each VLAN. It works, but it needs a cable, and a port at each end, for every VLAN. If SW2's meeting room ever wanted a guest port, VLAN 20 would need a second cable down the hallway, or one cable that carries both VLANs: a trunk, topic 03.1.3.
And a confession. Since week one, this course has said the kiosk is on "a different floor". It's on the same floor, three ports from Noor. The floor was only ever a figure of speech. The VLAN was the fact.
The VLAN never checked the floor plan before deciding who belongs.
10:00 a.m. · Two labels, two jobs
Sam has one more: "If we're VLAN 10, why does everyone's address start with 192.0.2?"
A VLAN and a subnet are two labels with two jobs. The VLAN is a Layer 2 idea: which devices share frames, broadcasts included. The subnet is a Layer 3 idea: which addresses are local, and when a host has to use its default gateway. They usually line up, by design: the devices in one VLAN are typically in one subnet, and devices in different VLANs in different subnets. Here, VLAN 10 is 192.0.2.0/24 and VLAN 20 is 203.0.113.0/24. There's no 10 in the first and no 20 in the second, and there doesn't need to be.
VLAN 10 is not a demand that every laptop's address end in .10. Numbers can look friendly without being the same fact.
10:30 a.m. · The boarding pass, explained
Back to Lisbon. A guest at the kiosk, 203.0.113.40, sent a print job to the printer, 192.0.2.50, in the other subnet.
Here's what happened. The printer is in another subnet, so the kiosk did what any host does: it sent the packet to its default gateway, R1, in a frame addressed to R1 G0/1's MAC, inside VLAN 20. R1 routed it. 192.0.2.50 is in the subnet on R1's G0/0, so R1 sent the same packet out G0/0, in a brand-new frame from its own MAC to the printer's, inside VLAN 10. LAB-SW1 switched two frames, each inside its own VLAN, and never moved a frame from one VLAN to the other.
Put in one line: the frame says R1, the packet says printer.
So Maya was half right. The kiosk can't see the printer: none of its frames, broadcasts included, has ever reached VLAN 10. But it can reach the printer, because whoever set up the kiosk gave it the printer's address, and R1 routes between the two subnets. To forward packets between VLANs, a network needs a router, or a switch that can route, called a Layer 3 switch or multilayer switch (topic 05.1.6). R1 with one cable in each VLAN is the simplest way to picture it. Other ways come in topic 05.1.5.
The packet can visit the other VLAN. Its local frame can't simply wander across the divider.
That's the other half. A VLAN keeps frames apart. It isn't a lock on packets, and it doesn't encrypt anything. Deciding which packets may cross R1 is a job for an access control list (topic 08.2.1). Maya writes it in her notebook, under "things the auditor will ask".
Noor: "So my printer's on the internet now?" "It's somewhere R1 can reach," says Maya. "That's a different thing. It's on my list."
11:00 a.m. · Why split at all?
Sam: "So why bother with VLANs, if packets can cross anyway?" Start with the kiosk.
Splitting a LAN into VLANs, each with fewer devices, often helps. The usual reasons:
- Less work for every host. A broadcast is received and processed by every other host in its VLAN, so fewer hosts per VLAN means fewer wasted interruptions.
- Less exposure. Fewer hosts receive the copies a switch floods: broadcasts, multicasts and unknown unicasts. A device gets a copy of every broadcast in its own broadcast domain, ARP requests included, and topic 08.3.2 shows how an attacker abuses exactly that.
- A policy per VLAN. Different VLANs can get different security policies.
- Groups by team, not by desk, as Eli showed.
- Faster fixes. For many problems, the set of devices affected is the broadcast domain, so a smaller one means fewer places to look.
- Less work for Spanning Tree, when a VLAN is kept to a single access switch (topic 03.3).
Each of those reduces something. None of them is a guarantee.
The same readings as the board, for every choice it offers.
| Who asks | Ports | Its VLAN | Who gets a copy |
|---|---|---|---|
| Maya | 8:55, Fa0/5 shut down | VLAN 10 | Noor, Printer, Eli, R1 G0/0 |
| Maya | Sam's desk in VLAN 10 | VLAN 10 | Noor, Printer, Sam, Eli, R1 G0/0 |
| Maya | Sam's desk in VLAN 20 | VLAN 10 | Noor, Printer, Eli, R1 G0/0 |
| Maya | every port in one VLAN, no guest cable to R1 | VLAN 1 | Noor, Printer, Guest kiosk, Sam, Eli, R1 G0/0 |
| Noor | 8:55, Fa0/5 shut down | VLAN 10 | Maya, Printer, Eli, R1 G0/0 |
| Noor | Sam's desk in VLAN 10 | VLAN 10 | Maya, Printer, Sam, Eli, R1 G0/0 |
| Noor | Sam's desk in VLAN 20 | VLAN 10 | Maya, Printer, Eli, R1 G0/0 |
| Noor | every port in one VLAN, no guest cable to R1 | VLAN 1 | Maya, Printer, Guest kiosk, Sam, Eli, R1 G0/0 |
| the printer | 8:55, Fa0/5 shut down | VLAN 10 | Maya, Noor, Eli, R1 G0/0 |
| the printer | Sam's desk in VLAN 10 | VLAN 10 | Maya, Noor, Sam, Eli, R1 G0/0 |
| the printer | Sam's desk in VLAN 20 | VLAN 10 | Maya, Noor, Eli, R1 G0/0 |
| the printer | every port in one VLAN, no guest cable to R1 | VLAN 1 | Maya, Noor, Guest kiosk, Sam, Eli, R1 G0/0 |
| Sam | Sam's desk in VLAN 10 | VLAN 10 | Maya, Noor, Printer, Eli, R1 G0/0 |
| Sam | Sam's desk in VLAN 20 | VLAN 20 | Guest kiosk, R1 G0/1 |
| Sam | every port in one VLAN, no guest cable to R1 | VLAN 1 | Maya, Noor, Printer, Guest kiosk, Eli, R1 G0/0 |
| the kiosk | 8:55, Fa0/5 shut down | VLAN 20 | R1 G0/1 |
| the kiosk | Sam's desk in VLAN 10 | VLAN 20 | R1 G0/1 |
| the kiosk | Sam's desk in VLAN 20 | VLAN 20 | Sam, R1 G0/1 |
| the kiosk | every port in one VLAN, no guest cable to R1 | VLAN 1 | Maya, Noor, Printer, Sam, Eli, R1 G0/0 |
| Eli | 8:55, Fa0/5 shut down | VLAN 10 | Maya, Noor, Printer, R1 G0/0 |
| Eli | Sam's desk in VLAN 10 | VLAN 10 | Maya, Noor, Printer, Sam, R1 G0/0 |
| Eli | Sam's desk in VLAN 20 | VLAN 10 | Maya, Noor, Printer, R1 G0/0 |
| Eli | every port in one VLAN, no guest cable to R1 | VLAN 1 | Maya, Noor, Printer, Guest kiosk, Sam, R1 G0/0 |
The printer has been spared the kiosk's questions since week one, and would like that noted.
11:30 a.m. · Your shift
Before lunch, Maya writes LAB-SW1 up for Sam: every connected port, its VLAN, and that VLAN's subnet.
| Port | What's on it | VLAN | Subnet |
|---|---|---|---|
| Fa0/1 | Maya | VLAN 10 | 192.0.2.0/24 |
| Fa0/2 | Noor | VLAN 10 | 192.0.2.0/24 |
| Fa0/3 | Printer | VLAN 10 | 192.0.2.0/24 |
| Fa0/4 | Guest kiosk | VLAN 20 | 203.0.113.0/24 |
| Fa0/5 | Sam | VLAN 10 | 192.0.2.0/24 |
| Fa0/8 | R1 G0/1 | VLAN 20 | 203.0.113.0/24 |
| Gi0/1 | SW2 (Eli behind it) | VLAN 10 | 192.0.2.0/24 |
| Gi0/2 | R1 G0/0 | VLAN 10 | 192.0.2.0/24 |
And here is what LAB-SW1 learned this morning, read off the switch itself. Look at the Vlan column.
LAB-SW1# show mac address-table dynamic
Mac Address Table
-------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- -----
10 0200.0000.0110 DYNAMIC Gi0/2
10 0200.0000.0210 DYNAMIC Fa0/1
10 0200.0000.0230 DYNAMIC Gi0/1
10 0200.0000.0250 DYNAMIC Fa0/3
10 0200.0000.0260 DYNAMIC Fa0/5
20 0200.0000.0120 DYNAMIC Fa0/8
20 0200.0000.0240 DYNAMIC Fa0/4
Total Mac Addresses for this criterion: 7- which MAC this switch learned, in which VLAN, on which port
- that two rows in different VLANs can reach each other: that takes a router, and this table knows nothing about routing
Four questions to finish.
Five lines to keep
- A VLAN is a broadcast domain the switch makes by configuration.
- A broadcast stays with the ports in its VLAN, however near or far they are.
- An access port puts an ordinary device's frames in one VLAN, and the device never knows.
- A Layer 2 switch never moves a frame between VLANs.
- Different VLANs can still talk, through a router, if its routes and the rules on it allow.
Maya's lunch will be a long one, as usual.
Next, 03.1.2: how do we tell LAB-SW1 which VLAN each access port uses, and how do we prove it took effect?
The interactive lesson
The whole lesson, with its drawings and its questions.
