Networking & IoT · Interview question

What's the difference between a switch and a router in terms of these layers?

A strong answer

They operate at different layers and forward on different addresses. A switch is a layer-2 (Link layer) device: it forwards Ethernet frames based on MAC addresses, learning which MAC lives on which port and switching frames within a single local network (broadcast domain). A router is a layer-3 (Internet layer) device: it forwards IP packets based on IP addresses, connecting different networks and making routing decisions toward a destination across the internet, decrementing the TTL and re-framing for the next link. So a switch moves frames around inside one network using hardware addresses, while a router moves packets between networks using logical IP addresses and is the device that gives you internet reach beyond your local subnet. In encapsulation terms, a switch only inspects the frame's MAC header, whereas a router strips to the IP header to route, then re-encapsulates in a new link-layer frame for the outgoing interface. This is also why your device needs a default gateway (a router's IP) to reach anything off its local subnet.

What a weak answer sounds like

You know the answer. Do you know what gets you dinged?

Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.

From the lesson

OSI vs TCP/IP Model

Why networking is split into stacked layers, how the 7-layer OSI reference maps onto the 4-layer TCP/IP model the internet actually runs on, and how encapsulation wraps your data.

More OSI vs TCP/IP Model questions

Browse all 472 interview questions
What's the difference between a switch and a router in terms of these layers? | EmbeddedPrep.io