Hub vs Switch vs Router: What Is the Difference?
Understand the difference between a hub, switch, and router — OSI layers, forwarding logic, and when each is used, with interview Q&A.
Expected Interview Answer
A hub is a dumb Layer 1 device that repeats every incoming signal out of all its other ports, a switch is a smart Layer 2 device that reads MAC addresses to forward frames only to the port where the destination actually lives, and a router is a Layer 3 device that reads IP addresses to forward packets between different networks entirely.
A hub has no intelligence: it is an electrical repeater, so every device connected to it shares one collision domain and sees every other device’s traffic, which does not scale and creates unnecessary congestion. A switch replaces the hub inside a single network by learning which MAC address sits on which physical port, building a forwarding table, and sending each frame only out the correct port, which gives every port its own collision domain and dramatically cuts wasted traffic. A router operates one layer higher, connecting separate networks together (for example a home LAN to the internet) by reading the destination IP address, consulting a routing table, and forwarding the packet toward the next hop, while also usually doing NAT so private IPs can share one public IP. In short, a hub broadcasts blindly, a switch forwards intelligently within a network, and a router forwards intelligently between networks.
- Hubs are obsolete but explain why collision domains matter
- Switches isolate traffic per port, boosting LAN performance
- Routers connect distinct networks and handle inter-network routing
- Each device operates at a distinct OSI layer (1, 2, 3)
AI Mentor Explanation
A hub is like an old stadium announcer with one loudspeaker that repeats every message to the entire ground regardless of who it is for, wasting everyone’s attention. A switch is like a modern usher who reads the seat number on a note and walks it directly to that one row, leaving everyone else undisturbed. A router is like the transport desk that sends a message between two different stadiums entirely, choosing the correct highway to the other ground. The three roles never overlap: repeat everywhere, deliver locally, or connect separate venues.
Step-by-Step Explanation
Step 1
Hub (Layer 1)
Repeats every incoming electrical signal out of all other ports; one shared collision domain.
Step 2
Switch (Layer 2)
Learns MAC addresses per port and forwards frames only to the destination port.
Step 3
Router (Layer 3)
Reads destination IP addresses and forwards packets between distinct networks.
Step 4
Practical mapping
Most home devices are actually a switch + router + Wi-Fi access point combined in one box.
What Interviewer Expects
- Correct OSI layer for each device (1, 2, 3)
- Understands hubs create one shared collision domain
- Explains switches forward using MAC address tables
- Explains routers forward using IP addresses between networks
Common Mistakes
- Using “router” and “switch” interchangeably
- Thinking a hub is just a slower switch rather than a dumb repeater
- Forgetting a router typically also performs NAT
- Not knowing switches operate at Layer 2, not Layer 3
Best Answer (HR Friendly)
“A hub just repeats everything to everyone and is basically outdated, a switch is smart enough to send data only to the exact device that needs it inside one network, and a router connects entirely separate networks together, like linking your home network to the internet. I like explaining it as: hub shouts, switch whispers to the right person, router calls a different building.”
Code Example
# Show this machine’s default gateway (the router)
ip route show default
# Show the switch-learned neighbor table on this segment (ARP cache)
arp -a
# Trace the path across routers to a remote host
traceroute example.comFollow-up Questions
- Why do switches eliminate collisions that hubs cause?
- What is a Layer 3 switch and how does it blur this distinction?
- How does a router decide which interface to forward a packet out of?
- Why are hubs almost never used in modern networks?
MCQ Practice
1. Which device forwards data based on MAC addresses?
A switch builds a MAC address table and forwards Ethernet frames to the correct port.
2. What is the main problem with using a hub instead of a switch?
A hub is a dumb repeater with no per-port intelligence, wasting bandwidth and causing collisions.
3. At which OSI layer does a router primarily operate?
Routers forward packets based on Layer 3 (Network layer) IP addresses.
Flash Cards
What layer is a hub? — Layer 1 — a dumb electrical repeater with one shared collision domain.
What layer is a switch? — Layer 2 — forwards frames using a learned MAC address table.
What layer is a router? — Layer 3 — forwards packets between networks using IP addresses.
One-line distinction? — Hub repeats blindly, switch forwards locally, router connects networks.