What a Layer 2 switch does
A Layer 2 switch works with frames. It learns source MAC addresses into a table, and forwards each frame to the port that leads to the destination MAC within the same VLAN. It never looks at IP addresses to decide where a frame goes. Devices in different VLANs are in different networks, so something else has to route between them.
What a Layer 3 switch adds
A Layer 3 (multilayer) switch is a Layer 2 switch that also has a routing table and can route between VLANs. It does this in specialised hardware, so routing between VLANs runs at the same speed as switching. It gets there with two kinds of Layer 3 interface:
- SVI (switch virtual interface): a virtual interface for a VLAN, such as
interface Vlan10. Its IP address is the default gateway for devices in that VLAN. - Routed port: a physical port changed to a Layer 3 interface with
no switchport, used for point-to-point links to routers or other Layer 3 switches.
Side by side
On small screens, swipe sideways or focus the diagram and use the arrow keys.
How to configure a Layer 3 switch
Commands are based on Cisco IOS documentation and have not been run on a lab device here.
ip routing
!
interface Vlan10
ip address 192.168.10.1 255.255.255.0
no shutdown
interface Vlan20
ip address 192.168.20.1 255.255.255.0
no shutdown
!
interface GigabitEthernet1/0/48
no switchport
ip address 10.0.0.2 255.255.255.252
!
ip route 0.0.0.0 0.0.0.0 10.0.0.1ip routing turns routing on. Each SVI is the gateway for its VLAN. The routed port connects to the upstream router, and a default route sends everything else there.
An SVI comes up only when its VLAN exists and at least one port in that VLAN is up (an access port, or a trunk that carries it). If show ip interface brief shows Vlan10 up/down, check that.
SW1#show ip route C 192.168.10.0/24 is directly connected, Vlan10 C 192.168.20.0/24 is directly connected, Vlan20 C 10.0.0.0/30 is directly connected, GigabitEthernet1/0/48 S* 0.0.0.0/0 [1/0] via 10.0.0.1
Which to use where
- Access layer: Layer 2 switches. Cheap, many ports, and they keep VLANs local to a wiring closet.
- Distribution and core: Layer 3 switches, so VLANs are routed at wire speed and links between switches can be routed instead of switched.
- Small office: a single Layer 3 switch can do the job of a switch and a router, as long as there are no WAN services to run.
- WAN edge: a router or firewall for NAT, VPN and the provider interfaces.
Layer 2 vs Layer 3 switch in short
- Layer 2 forwards by MAC within a VLAN; Layer 3 also routes between VLANs by IP.
- SVIs are VLAN gateways;
no switchportmakes a routed port. ip routingmust be on for the switch to route.- An SVI is up only when its VLAN exists and a port in it is up.
Test yourself
Which command allows a Layer 3 switch to route between its SVIs?
What turns a switch port into a routed port?
A Layer 2 switch forwards a frame based on which field?
interface Vlan10 shows up/down. What is a likely cause?
Where does a Layer 3 switch typically sit in a campus?