Router vs Switch: What's the Difference?
Here's the short answer: a switch connects devices inside one local network and forwards Ethernet frames using MAC addresses at Layer 2, while a router connects separate networks together and forwards packets using IP addresses at Layer 3. Put another way, a switch builds a network out of nearby devices; a router links networks to each other, including to the internet.
| At a glance | Router | Switch |
|---|---|---|
| OSI layer | Layer 3 — Network | Layer 2 — Data Link |
| Address used | IP address (32-bit IPv4 / 128-bit IPv6) | MAC address (48-bit) |
| Forwarding unit | Packets | Frames |
| Table it builds | Routing table | MAC address table |
| Scope | Connects separate networks (incl. the internet) | Connects devices inside one network |
| Broadcast domains | Separates them — blocks broadcasts | One — floods broadcasts to all ports |
| Typical job | Link LANs and reach the internet | Build a LAN |
Frames, Packets, and the Two Layers That Matter
Every explanation of this topic comes back to the OSI model, which has seven layers (Physical, Data Link, Network, Transport, Session, Presentation, Application). Only two matter here: Layer 2, the Data Link layer, where a switch lives, and Layer 3, the Network layer, where a router lives. The simpler TCP/IP model folds these ideas into four layers, but the same distinction holds.
A switch moves frames, which are addressed by 48-bit MAC addresses burned into each network card. A router moves packets, which are addressed by IP addresses (32-bit for IPv4, 128-bit for IPv6). A MAC address is a local, flat identity that only has meaning inside one network segment; an IP address is hierarchical and routable, so it can be used to reach a device across the world.
A rough analogy: a MAC address is like the specific mailbox on one street, while an IP address is the full postal address with a city and ZIP code that lets a letter travel between towns. Switches deliver on the street; routers move mail between towns.
The Problem Each Solves: Collision and Broadcast Domains
Before switches, hubs simply repeated every incoming signal out of every port, so all devices shared one collision domain and constantly stepped on each other's transmissions. A switch solves this by giving every port its own collision domain and running full-duplex, so well-designed modern LANs effectively don't have collisions at all.
But a switch still floods broadcast traffic out of every port in the same network, so by default all of a switch's ports sit in a single broadcast domain. Pack too many devices into one broadcast domain and broadcast chatter starts to waste bandwidth and CPU on every host.
A router does not forward broadcasts. Each router interface bounds a broadcast domain, so routers (or VLANs configured on a switch) are how you break one large, noisy network into smaller, isolated ones. That is the core reason both devices exist: switches scale connectivity cheaply, routers keep networks separated and reachable.
How a Switch Thinks: Learning MAC Addresses
A switch works almost automatically. As frames arrive, it reads each frame's source MAC address and records which port that device is on, building a MAC address table. When a later frame is destined for a MAC it already knows, the switch forwards it out only that one port; if the destination is unknown, it floods the frame to all ports in that network and learns the answer from the reply.
This is fast, hardware-based, and needs no configuration to start working — a switch does not care about IP addresses at all. Because switches flood unknown and broadcast traffic, redundant cabling between switches can create endless loops. Spanning Tree Protocol (STP) prevents Layer 2 loops by electing a root bridge (the switch with the lowest bridge ID) and blocking redundant paths until they are needed.
How a Router Thinks: Choosing a Path by IP
A router is more deliberate. For every packet, it consults a routing table of known destination networks and picks the most specific entry that matches — the longest-prefix match. When two sources offer a route to the same destination, administrative distance is the tiebreaker that decides which source the router trusts more.
Networks are carved up with subnet masks, which split an address into network bits and host bits (usable hosts per subnet = 2^host-bits − 2, with /31 and /32 as special cases). When a host needs to reach something outside its own subnet, it sends the traffic to its default gateway — the router interface that owns the default route, 0.0.0.0/0.
Routers also do the heavier work at network edges: NAT/PAT to share one public IP among many hosts, ACLs to permit or deny traffic, and dynamic routing protocols such as OSPF. Those are topics for the step-by-step configuration guides; conceptually, just remember a router's whole job is deciding how to get a packet from one network to another.
Where a Layer 3 Switch Fits (and VLANs)
VLANs let a single physical switch behave like several separate switches, each its own broadcast domain, without extra hardware. Traffic between two VLANs must be routed, and links that carry multiple VLANs between switches use 802.1Q tags to label each frame (the native VLAN is left untagged).
A Layer 3 switch is the hybrid: it switches frames within a VLAN at wire speed and can also route between VLANs internally, so packets don't have to leave the switch and come back through a separate router. That makes it the workhorse for routing inside a campus or office LAN.
A useful rule of thumb: reach for a Layer 3 switch when you need fast internal routing between many VLANs, and a router when you need the internet edge, WAN links, NAT, or richer security features. Exact capabilities vary by model, so treat this as guidance rather than a hard line.
Side-by-Side, and Common Beginner Gotchas
Quick comparison — Layer: switch = Layer 2, router = Layer 3. Addresses: switch uses MAC (48-bit), router uses IP (IPv4 32-bit / IPv6 128-bit). Forwarding unit: frames vs packets. Scope: switch stays within one network, router moves between networks. Domains: a switch is one broadcast domain per VLAN with many collision domains, while a router separates broadcast domains. Table built: switch learns a MAC address table, router uses a routing table with longest-prefix match. Typical job: switch connects PCs, printers, and access points in a building; router connects that LAN to other networks and the internet.
Gotcha 1: a managed switch can have a management IP address, but that address is only for you to administer it — it still forwards user traffic by MAC at Layer 2 and does not route. Having an IP does not make a device a router. Gotcha 2: the box most people call a home 'router' is really a router, a small switch, Wi-Fi access point, and firewall combined, which is exactly why the two devices get confused.
Gotcha 3: a plain Layer 2 switch cannot move traffic between two different subnets or VLANs — if they can't talk, that is expected until a router or Layer 3 switch routes between them. Gotcha 4: hosts need a correct default gateway set, or they can reach their own subnet but nothing beyond it.
Frequently asked questions
Do I really need both a router and a switch for a small network?
Often not for a handful of devices — a typical home or small-office all-in-one box already contains a router, a small switch, and Wi-Fi in one unit. You add a dedicated switch when you run out of wired ports, and you add separate routing (a router or a Layer 3 switch) when you want to split the network into multiple segments or VLANs that stay isolated from one another.
Why can't a switch just do everything a router does?
Because a plain switch forwards by MAC address within a single network and has no concept of IP routing — it doesn't know how to reach other networks, choose paths by longest-prefix match, hand off to a default gateway, or perform NAT. Those are Layer 3 jobs a router performs. A Layer 3 switch blurs this line by adding routing between VLANs, but a standard Layer 2 switch simply isn't built to route between networks.
Is a Layer 3 switch the same thing as a router?
Not quite. Both forward by IP address at Layer 3, but a Layer 3 switch is optimized for very fast routing between VLANs inside a LAN and usually lacks WAN interfaces and edge features like NAT. A router is built for connecting different networks, the internet edge, and advanced services. In practice you use a Layer 3 switch for internal routing and a router at the boundary; exact feature sets vary by model, so check the specific device.
Now build it on real Cisco IOS
Concepts stick when you configure them. Try a free graded lab, then grade your own config against the answer key.