Network Bytes · Episode 93 · CCNA 2.1
"Layer 3 switches and SVIs"
A Layer 3 switch routes between VLANs itself, with no separate router. Each routed VLAN gets a switched virtual interface (SVI) whose IP address is that VLAN's default gateway, and with ip routing turned on the switch forwards between VLANs in hardware.
The problem with router on a stick
Hosts in different VLANs are in different networks, so traffic between them has to be routed. With router on a stick (EP82), one trunk links the switch to a router. A packet from VLAN 10 to VLAN 20 goes up the trunk to the router (the "mailroom"), gets routed, and comes back down the same trunk. Every inter-VLAN packet crosses that one link twice, so the trunk can get busy.
The mailroom moves inside the switch
A Layer 3 switch is a switch that can also route. Instead of sending traffic out to a router, it routes between VLANs itself. Cisco Catalyst switches such as the 3650, 3850 and 9000 families can do this. Because the switch routes in hardware (special chips called ASICs, using Cisco Express Forwarding), inter-VLAN traffic is fast and never needs to leave the box.
SVIs: one virtual interface per VLAN
A switched virtual interface (SVI) is a logical Layer 3 interface for a VLAN. It has no physical port of its own; it stands for the whole VLAN inside the switch. You create it and give it an address:
`` interface vlan 10 ip address 192.168.10.1 255.255.255.0 ``
That address, 192.168.10.1, is what hosts in VLAN 10 use as their default gateway. Each VLAN that should be routed gets its own SVI with an address in that VLAN's subnet.
An SVI only comes up/up when its VLAN exists on the switch and has at least one active port (or a trunk carrying it).
Turn on routing
On many Cisco Layer 3 switches, the SVIs alone are not enough: routing between them needs the global command:
`` ip routing ``
Some platforms have it on by default. With it on, the switch builds a routing table from its SVIs' connected networks and forwards between VLANs.
Try it yourself
In Cisco Packet Tracer, drop in a Catalyst 3650 and a few PCs. Put each PC in its own VLAN, create an SVI for each VLAN with an address in that PC's subnet, and set each PC's default gateway to its SVI. Before you type ip routing, try a ping between the PCs; then turn it on and ping again. Use show ip interface brief to see the SVIs come up and show ip route to see the connected routes.
Good to know
- CCNA 2.1 includes inter-VLAN connectivity, and 1.1 lists Layer 2 and Layer 3 switches (EP82 covers router on a stick and named Layer 3 switches with SVIs as the next step).
- An SVI is a logical Layer 3 interface for a VLAN, created with
interface vlan <id>; given an IP address, it becomes the default gateway for hosts in that VLAN. - On many Cisco Layer 3 switches (for example Catalyst 3650/3850/9000), routing between SVIs needs the global
ip routingcommand; some platforms have it on by default. - The VLAN must exist and have at least one active port (or trunk) for its SVI to come up/up.
- The switch routes in hardware (ASICs, using CEF), which is why it is faster than router on a stick, where every inter-VLAN packet crosses the trunk twice.
- A Layer 2 switch also has an SVI (often Vlan1) for management only, which doesn't route.
- Layer 3 switches can also use routed ports (
no switchport), which the short skips. - "Mailroom" is the same analogy as EP82. The example addresses are private.
For CCNA learners
CCNA exam topic 2.1 includes inter-VLAN connectivity. Know how router on a stick and a Layer 3 switch compare, that an SVI is created with interface vlan <id> and acts as the VLAN's default gateway, and that ip routing turns on routing between SVIs.
Answer to the comment question
2 more. Each routed VLAN needs its own SVI. VLAN 10 already has one, so VLAN 20 and VLAN 30 still need one each: interface vlan 20 and interface vlan 30, each with an IP address in its VLAN's subnet.
Test your knowledge
Quick quiz: "Layer 3 switches and SVIs"
4 multiple-choice questions. Pick one answer for each, then check how you did.
Sources
- Cisco, "Configure InterVLAN Routing with Catalyst Switches": a Layer 3 switch routes between VLANs with an SVI per VLAN, "interface vlan" plus an IP address, and the global "ip routing" command
- Cisco, "Configure Inter-VLAN Routing with Catalyst 9000 Switches": SVI configuration on current Catalyst switches
- Study-CCNA, "Layer 3 switch InterVLAN routing configuration": SVIs as the default gateways for each VLAN, compared with router on a stick
- Cisco, "CCNA 200-301 v1.1 exam topics": 2.1 configure and verify VLANs (normal range) spanning multiple switches, including InterVLAN connectivity; 1.1.b Layer 2 and Layer 3 switches
Video transcript
How can one switch route between VLANs without a separate router?
Router on a stick sends traffic up one cable to a mailroom, the router, and back down. That one link gets busy.
A Layer 3 switch puts the mailroom inside the switch itself.
For each VLAN, you create a virtual interface called an SVI, and give it an IP address. That address is the VLAN's default gateway.
Turn on IP routing, and the switch forwards between VLANs in its own hardware, fast, with no trip up a cable.
A switch routes for VLANs 10, 20 and 30. VLAN 10 already has an SVI. How many more do you need? Comment your answer below!
That's your byte.
More from Network Bytes
- EP91"Voice VLANs: a phone and a PC on one port"
- EP92"QoS policing vs shaping"
- EP94"OSPF router ID: how it's chosen"
- EP95"enable secret vs enable password"