Unit 2: Network Devices·Lesson 2.9 (9 of 10 in this unit)·14 of 104 in the Network Fundamentals course
Routing vs Switching
Switches and routers both move data, which is why they get confused. The difference is what each one reads, which table it uses, and where its job ends. Once you see that, most network designs make sense.
Beginner · 9 min read · Before this: Switches, Routers
Covers Layer 2 and Layer 3, MAC table and routing table, Broadcast domains and What changes on a hop.
Technical definition
Switching and routing are the two ways a network moves traffic. A switch forwards frames inside one network using MAC addresses at Layer 2. A router forwards packets between networks using IP addresses at Layer 3.
Switching stays in the LAN, routing crosses between networks
On small screens, swipe sideways or focus the diagram and use the arrow keys.
A switch reads the MAC address and leaves the frame alone. A router reads the IP address, drops the old frame header and builds a new one for the next link. The IP source and destination stay the same end to end.
What each one reads
A switch looks at the destination MAC address in the Ethernet frame and uses its MAC address table to send the frame out the right port. A router looks at the destination IP address in the packet and uses its routing table to choose the next hop and the outgoing interface.
Routing and switching compared
On small screens, swipe sideways or focus the diagram and use the arrow keys.
Header row, topics and answers use different colours so each row reads across.
What changes when a frame crosses a router
A switch forwards the frame as it is. A router receives the frame, removes the Layer 2 header, checks the IP packet, chooses the next hop, and builds a new frame for the next link. The MAC addresses change at every hop, because each link is its own network. The IP addresses stay the same, which is how the two hosts identify each other end to end.
Broadcast domains
A switch floods broadcasts to every port in the same VLAN, so all those ports share one broadcast domain. A router does not forward broadcasts, so each routed interface is a separate domain (see Broadcast domains). That is why large networks are divided into several routed networks: it keeps broadcast traffic local.
Using them together
Hosts on the same network reach each other through switches. When the destination is on another network, the host sends the frame to its default gateway, the router, which forwards it onward (see The default gateway). Real networks use both: switches to connect hosts, routers to connect networks.
Test yourself
Predict · scenario 1
A frame goes from PC1 to PC2 on the same VLAN through one switch. What does the switch read to forward it?
Predict · scenario 2
A packet crosses a router. Which values stay the same from source to destination?
Predict · scenario 3
Which device separates broadcast domains by default?
FAQ
Can a switch route?
A Layer 2 switch cannot. A Layer 3 switch can route between VLANs and networks as well as switch inside them. See Router vs Layer 3 switch.
Does a router change the IP addresses in a packet?
Normally not. A router rewrites the Ethernet header for each link, but the source and destination IP addresses stay the same end to end, unless NAT translates them.
Why does a router stop broadcasts?
A router forwards by IP destination and does not forward Layer 2 broadcasts, so each of its interfaces is its own broadcast domain.