← Lessons

quiz vs the machine

Silver1120

Networking

Switches Versus Routers

Separate the device that connects one network from the device that connects many.

4 min read · intro · beat Silver to climb

Two Different Jobs

People lump networking boxes together, but a switch and a router operate at different layers and solve different problems.

What A Switch Does

A switch works at the link layer and forwards Ethernet frames within a single local network.

  • It learns which MAC address lives on each port by watching traffic.
  • It forwards a frame only out the port toward its destination.
  • It keeps a local network fast and free of needless flooding.

A switch does not understand IP addresses or reach across networks.

What A Router Does

A router works at the network layer and forwards IP packets between different networks.

  • It reads the destination IP address and consults a routing table.
  • It picks the next hop toward the destination network.
  • It connects your local network to other networks and the internet.

How They Cooperate

In a typical setup, devices connect to a switch that forms the local network, and that switch connects to a router that links the local network to the wider world. Frames stay on the switch for local traffic, while anything bound for another network is handed to the router.

Key idea

A switch forwards frames by MAC address inside one local network, while a router forwards packets by IP address between separate networks.

Check yourself

Answer to earn rating on the learn ladder.

1. At which layer does a switch primarily operate?

2. What does a router use to decide where to forward a packet?