What is the difference between a Layer 2 and Layer 3 switch?
Why Interviewers Ask This
This is a classic screening question for Networking roles. Hiring managers ask it early in interviews to gauge your baseline understanding and determine if you can communicate technical concepts clearly.
Answer
A Layer 2 switch operates at the Data Link layer — it forwards Ethernet frames based on MAC addresses. It learns which MAC addresses are on which ports and builds a MAC address table (CAM table). Layer 2 switches cannot route between different networks/subnets — all connected devices must be in the same IP subnet (unless VLANs with a router are used). A Layer 3 switch (also called a multilayer switch) adds routing capabilities — it can route packets between different VLANs and IP subnets based on IP addresses, like a router. Layer 3 switches use specialized hardware (ASICs) for high-speed routing — much faster than software-based routers for inter-VLAN routing in large enterprise networks. Most enterprise core and distribution layer switches are Layer 3. Simplified: Layer 2 = switching by MAC; Layer 3 = switching AND routing by IP.
Common Mistake
Candidates often give textbook answers here. Interviewers are more impressed when you relate the concept to a specific problem you solved in a real Networking project.