Router vs Switch
Router operates at Layer 3 (Network) using IP addresses to connect DIFFERENT networks. Switch operates at Layer 2 (Data Link) using MAC addresses to connect devices within the SAME network.
Overview
Router and Switch are both network devices but operate at different OSI layers and serve different purposes.
Router — Layer 3 (Network Layer) - Operates at Layer 3 (Network Layer) - Uses IP addresses to make forwarding decisions - Connects DIFFERENT networks together - Routes packets between Network A and Network B - Example: home router connecting your LAN (192.168.1.0/24) to the internet - Maintains a routing table of known networks and next-hop paths
Key concepts
- Router
- Switch
- MAC Address Table (CAM Table)
- Routing Table
- L3 Switch
Interview questions
- What is the difference between a router and a switch?
- When would you use a Layer 3 switch instead of a router?
- How does a switch learn which MAC address is on which port?
- In AWS, what plays the role of a router and what plays the role of a switch?
Sign up free to read the full topic
More Networking topics
Start free on Cariara · Coding problems · System design studio