Explainer

Layer 2 vs Layer 3 Switch

The core difference is simple: a Layer 2 switch forwards Ethernet frames by MAC address within VLANs and cannot move traffic between subnets on its own, while a Layer 3 switch adds IP routing on top of that same switching, so it can forward packets between VLANs and hold a routing table. Put another way, an L2 switch keeps traffic inside each VLAN; an L3 switch also acts as the router between them.

Both boxes still do all the Layer 2 work: they learn source MAC addresses into a table, give every port its own collision domain, run full-duplex (so links have no collisions), and treat each VLAN as one broadcast domain. The L3 switch just layers a router's job on top, performed in hardware (ASIC) at wire speed. So the real question is never 'switch or router' in the abstract, it is whether this box needs to route between subnets by itself.

At a glanceLayer 2 SwitchLayer 3 Switch
OSI layerLayer 2 (data link) onlyLayers 2 and 3 (adds the network layer)
Forwards based onDestination MAC address (MAC/CAM table)MAC within a VLAN; destination IP (routing table) between VLANs
Inter-VLAN routingNo — needs a separate router or L3 switchYes — in hardware/ASIC via SVIs and routed ports
IP interfacesOne management IP (management VLAN SVI) for admin onlyAn SVI per VLAN plus routed ports, each an IP gateway for hosts
Routing tableNoneYes — static routes (AD 1) and dynamic protocols like OSPF (cost, AD 110)
Broadcast domainsOne per VLAN; does not cross between themOne per VLAN, and routes between those domains
Typical roleAccess layer — connect end devicesDistribution/core — fast inter-VLAN routing
WAN / edge featuresNoneLimited — mostly Ethernet, little or no NAT/VPN (still use a router)

What a Layer 2 switch does

A Layer 2 switch reads the destination MAC address of each incoming frame and forwards it out the correct port, building its MAC address table by learning the source MAC of frames it sees. It supports VLANs to segment the network, access ports (one untagged VLAN, to an end device), and 802.1Q trunks (many VLANs tagged, native VLAN untagged, between switches).

What it will not do is route. Traffic can move freely inside a VLAN, but a frame that needs to reach a different VLAN or subnet has to be handed to a router or an L3 switch. The switch itself typically has just a single management IP (on one management VLAN's SVI) so admins can reach it over SSH or SNMP — that address does not forward user traffic.

What a Layer 3 switch adds

A Layer 3 switch does everything above and adds routing. You give it Switched Virtual Interfaces (SVIs) — one virtual IP interface per VLAN that becomes the default gateway for hosts in that VLAN — and/or routed ports (a physical port taken out of switching and given an IP). It maintains a routing table and can run static routes or dynamic routing protocols.

The important part is that it performs this inter-VLAN routing in hardware (ASIC), so it routes at wire speed rather than in a slower software path. That makes it ideal for moving large volumes of traffic between VLANs inside a campus or data center.

The key differences

Forwarding basis: an L2 switch decides on MAC address; an L3 switch also decides on destination IP when a packet crosses VLANs.

Routing: an L2 switch has no routing table and cannot bridge subnets; an L3 switch holds a routing table and does inter-VLAN routing itself.

IP addressing: an L2 switch has one management IP; an L3 switch has an SVI (or routed-port IP) per VLAN that serves as a gateway.

Where they sit: L2 switches usually live at the access layer connecting endpoints, while L3 switches sit at the distribution or core layer aggregating and routing between VLANs.

When to use each — and L3 switch vs router

Use a Layer 2 switch at the access layer to connect PCs, phones, printers, and APs, and to carry VLANs up to a router or L3 switch. Use a Layer 3 switch when you have several VLANs on a LAN and want fast, local routing between them without hairpinning traffic through a separate router.

An L3 switch is not a full replacement for a router. It routes between LAN segments in ASIC at high speed and offers high Ethernet port density, but it is Ethernet-focused and usually lacks WAN interfaces and edge features (extensive NAT, VPN, WAN protocols). A router has fewer ports and often routes in software, but provides those WAN/edge services. The common design: L3 switch for internal inter-VLAN routing, a router at the Internet/WAN edge.

A common gotcha

On Cisco Catalyst switches that are Layer 3 capable, IP routing is disabled by default — the box behaves as a plain L2 switch until routing is turned on. If inter-VLAN traffic is not flowing, that is the first thing to check.

Also, an SVI only comes up when its VLAN exists and at least one active port is in that VLAN, so a gateway interface can sit 'down' even though it is configured. And because L3 switches typically have no NAT or WAN ports, do not expect one to replace the edge router — you still need a router to reach the Internet.

Frequently asked questions

Which is better, a Layer 2 or Layer 3 switch?

Neither is universally better — they do different jobs. A Layer 2 switch is the right, cheaper choice at the access layer where you just connect end devices and carry VLANs. A Layer 3 switch is better when you need fast routing between multiple VLANs on the LAN. Many networks use both: L2 switches at the edge, an L3 switch aggregating and routing between them.

When would I use a Layer 3 switch instead of a router?

Use a Layer 3 switch when you need high-speed, high-port-count routing between VLANs inside a LAN or campus — it routes in hardware (ASIC) at wire speed. Use a router when you need WAN connectivity or edge features an L3 switch usually lacks, such as NAT, VPN, or WAN interfaces. A typical setup pairs an L3 switch for internal inter-VLAN routing with a router at the Internet edge.

What's the main difference between a Layer 2 and Layer 3 switch?

A Layer 2 switch forwards frames by MAC address and cannot route between VLANs or subnets — it only has a management IP. A Layer 3 switch adds IP routing: SVIs and routed ports with gateway IPs, a routing table, and inter-VLAN routing done in hardware. In short, the L2 switch keeps traffic within VLANs, and the L3 switch also routes between them.

Now build it on real Cisco IOS

Concepts stick when you configure them. Try a free graded lab, then grade your own config against the answer key.