Routelearn.net
Course menu

Unit 2: Network DevicesLesson 2.4 (4 of 8 in this unit)8 of 84 in the Network Fundamentals course

What a router does

Why traffic between networks needs a router, and the forwarding decision it makes for every packet.

Beginner · 6 min read

Router is a Layer 3 device that connects different IP networks and forwards packets between them. For each packet, it compares the destination IP address with its routing table and sends the packet out of the interface towards the best matching route.

In simple terms: A router is the junction between networks. It reads where each packet is going and passes it one step closer, like a sorting office forwarding a letter towards the right town.

A real-life situation

PC1 sits in the main office. It needs a file from a server in the branch office. The two offices are different networks: PC1 is in 192.168.1.0/24 and the server is in 192.168.3.0/24. A Layer 2 switch can't help here, because it only moves frames within one network. Something has to carry the packet from one network to the other. That something is a router.

What a router is

A router is a device that connects different IP networks and moves packets between them. It works at Layer 3 of the OSI model, the network layer, which is the layer that deals with IP addresses.

Each router interface is in a different network. When a packet arrives, the router looks at its destination IP address, checks its routing table (its list of known networks) and sends the packet out of the interface that leads closer to that address. This choice is called the forwarding decision.

SwitchRouter
Works atLayer 2 (data link)Layer 3 (network)
Looks atDestination MAC addressDestination IP address
UsesMAC address tableRouting table
Moves trafficWithin one network (one VLAN)Between different networks
Unknown destinationFloods the frame within the VLANDrops the packet (unless a default route exists)

The default gateway

PC1 doesn't know anything about other networks. It only knows its own IP address and subnet mask, which are enough to tell whether a destination is local (same network) or remote. For remote destinations, it sends the packet to its default gateway: the router interface on its own network, here R1's 192.168.1.1.

💡 In simple terms: the default gateway is the one road out of the neighbourhood. If the address isn't on your street, you take that road and let the routers beyond it work out the rest of the way.

Hop by hop

No single router decides the whole path. Each router only decides the next hop: the next router to pass the packet to. That router then makes its own decision, and so on. Watch the packet cross this three-router network:

192.168.1.0/24203.0.113.0/3010.0.12.0/3010.0.23.0/30192.168.2.0/24192.168.3.0/24PC1192.168.1.10ISP203.0.113.1R1R2R3PC2192.168.2.10Server192.168.3.10
  1. 1. PC1: not local. 192.168.3.10 is outside 192.168.1.0/24, so PC1 sends the packet to its default gateway, R1.
  2. 2. R1 decides: its routing table says 192.168.3.0/24 is reached through R2 (10.0.12.2), so it sends the packet out of Gi0/1.
  3. 3. R2 decides: 192.168.3.0/24 is reached through R3 (10.0.23.2), so R2 forwards the packet to R3.
  4. 4. R3 delivers: 192.168.3.0/24 is directly connected, so R3 delivers the packet straight to the server.

Why it works this way

Keeping each decision local is what lets routing scale. A router doesn't need to know every device on the internet. It only needs to know which neighbour is closer to each network. Along the way, one thing stays the same and two things change at every router:

  • The IP addresses stay the same. Source 192.168.1.10 and destination 192.168.3.10 from start to end (as long as no NAT is involved).
  • The Ethernet frame is rebuilt. Each router removes the old frame and wraps the packet in a new one, with new source and destination MAC addresses for the next link.
  • The TTL goes down by one. TTL (time to live) is a counter in the IP header. If it reaches zero, the router drops the packet. This stops a packet from looping forever if the routes are wrong.
Step 1 of 5
  1. PC1Src 192.168.1.10
  2. R1Default gateway · TTL 64 → 63
  3. R2Next hop 10.0.23.2 · TTL → 62
  4. R3Directly connected · TTL → 61
  5. ServerDst 192.168.3.10
The same journey as a simple path: each router makes its own next-hop decision.

How to verify it

A router can only route through interfaces that are up and have an IP address, so check that first. The output below is based on Cisco documentation, not captured from a lab device.

Example output · based on Cisco documentation; exact format varies by platform and software version
R1#show ip interface brief
Interface              IP-Address      OK? Method Status                Protocol
GigabitEthernet0/0     192.168.1.1     YES manual up                    up
GigabitEthernet0/1     10.0.12.1       YES manual up                    up
GigabitEthernet0/2     203.0.113.2     YES manual up                    up
GigabitEthernet0/3     unassigned      YES unset  administratively down down
What to look for: each working interface needs an IP-Address and up in both the Status and Protocol columns. Gi0/3 is administratively down (shut down) and has no address, so R1 can't route through it.

On PC1, ipconfig (Windows) or ip route (Linux, the default via line) shows the default gateway. If it is missing or wrong, PC1 can reach its own network but nothing beyond it.

Check yourself

Predict · scenario 1

PC1 (192.168.1.10/24) sends data to 192.168.1.50. Where does it send the packet?

Predict · scenario 2

As the packet from PC1 passes through R1, R2 and R3, what stays the same?

Predict · scenario 3

A router has no route for a packet's destination and no default route. What happens?