Router vs Switch: What is the Difference?
Router vs switch compared — Layer 2 vs Layer 3, MAC vs IP forwarding, and real use cases with commands and interview practice.
Expected Interview Answer
A switch connects devices within a single local network and forwards frames between them using MAC addresses, while a router connects separate networks together and forwards packets between them using IP addresses, typically providing the path to the internet.
A switch operates at Layer 2 (Data Link), builds a MAC address table by observing traffic, and forwards each frame only out the port where the destination device lives, making local communication efficient. A router operates at Layer 3 (Network), examines the destination IP address, consults a routing table, and forwards packets between different networks or subnets, often performing NAT to share one public IP among many local devices. A home "router" is usually a combined device with router, switch, and Wi-Fi access point functions in one box, which is a common source of confusion. Interviewers use this question to check you can separate Layer 2 local switching from Layer 3 inter-network routing.
- Switch: fast, efficient forwarding within one local network
- Router: connects distinct networks and enables internet access
- Switch: builds and uses a MAC address table (Layer 2)
- Router: uses IP addresses and a routing table (Layer 3)
AI Mentor Explanation
A switch is like the twelfth man ferrying messages between players on the same field — it knows exactly where every player stands and delivers each message directly to the right one without shouting to the whole ground. A router is like the team liaison who sends messages between two different grounds entirely, deciding which road or transport route gets a message from one stadium to another. One handles fast delivery within the same field; the other bridges completely separate fields.
Step-by-Step Explanation
Step 1
Frame arrives at switch
A switch reads the destination MAC address and checks its address table.
Step 2
Switch forwards locally
The frame is sent out only the port for that MAC, keeping traffic within the local network.
Step 3
Packet reaches router
For a different network, the router reads the destination IP and consults its routing table.
Step 4
Router forwards between networks
The router sends the packet out the correct interface toward the destination network, possibly applying NAT.
What Interviewer Expects
- Switch operates at Layer 2 using MAC addresses within one network
- Router operates at Layer 3 using IP addresses between networks
- Understanding that home "routers" combine router, switch, and access point
- Correct example use cases for each device
Common Mistakes
- Saying a switch can connect to the internet on its own
- Confusing MAC-address-based switching with IP-based routing
- Assuming a home router is only a router with no switch functionality
- Not mentioning Layer 2 vs Layer 3 as the fundamental distinction
Best Answer (HR Friendly)
“A switch is what connects all the devices within one local network, like every computer in an office, and moves data between them very quickly. A router is what connects that entire local network to other networks, like the internet, deciding the best path for traffic to travel outside.”
Code Example
# On a switch: view the MAC address table
show mac address-table
# On a router: view the IP routing table
show ip route
# On a Linux host: view the local ARP (MAC) cache and routing table
ip neigh show
ip route showFollow-up Questions
- What is a Layer 3 switch and how does it blend both roles?
- How does a router decide the best path using a routing table?
- What is VLAN tagging and why do switches use it?
- How does ARP relate to switching and routing?
MCQ Practice
1. Which OSI layer does a traditional switch primarily operate at?
Switches forward frames using MAC addresses at Layer 2 (Data Link).
2. What does a router use to decide where to forward a packet?
Routers examine the destination IP address and consult a routing table.
3. What is a common example of a device combining router, switch, and access point?
Consumer home routers typically bundle routing, switching, and wireless access point functions in one unit.
Flash Cards
Switch in one line? — Connects devices within one local network using MAC addresses (Layer 2).
Router in one line? — Connects separate networks together using IP addresses (Layer 3).
What table does a switch build? — A MAC address table mapping addresses to physical ports.
What does a home "router" usually include? — A combined router, switch, and Wi-Fi access point in one device.