Layer 2 vs Layer 3: Switching vs Routing
The core distinction in networking: Layer 2 forwards frames within a network using MAC addresses (switching), while Layer 3 forwards packets between networks using IP addresses (routing). Nearly every device and protocol lives at one of these two layers.
Side by side
| Factor | Layer 2 | Layer 3 |
|---|---|---|
| Addresses | MAC addresses | IP addresses |
| Scope | Within one network | Between networks |
| Device | Switch | Router / L3 switch |
| Forwarding by | Frame → destination MAC | Packet → destination IP |
| Broadcast domains | One (per VLAN) | Separated |
The details that matter
Layer 2 is the local delivery layer — a switch reads destination MAC addresses and forwards frames to the right port within the same network. Layer 3 is the inter-network layer — a router reads destination IP addresses and forwards packets between different networks, choosing paths and separating broadcast domains. A packet keeps the same source/destination IP end to end (Layer 3), but its MAC addresses change at every hop (Layer 2). A Layer 3 switch does both — switching within VLANs and routing between them. This split is the backbone of the OSI model and a constant interview theme.
Frequently asked questions
What is the difference between Layer 2 and Layer 3?
Layer 2 forwards frames within a network using MAC addresses (switching); Layer 3 forwards packets between networks using IP addresses (routing) and separates broadcast domains.
Is a switch Layer 2 or Layer 3?
A standard switch is Layer 2; a multilayer (Layer 3) switch also routes between VLANs using IP addresses at hardware speed.
Do MAC and IP addresses both change as a packet travels?
The IP addresses stay the same end to end (Layer 3); the MAC addresses change at each hop (Layer 2) as the packet is re-framed for the next link.
Related articles
Want hands-on training?
Learn this on real Cisco lab devices with placement support at Attila Technologies, Ahmedabad.