A Router is a Layer 3 device designed to connect different networks together. While switches use MAC addresses, routers use IP Addresses to make forwarding decisions.
Decision Making
Routers maintain a Routing Table (RIB) which acts as a map of the network, containing the best paths to all known destinations.
The Routing Table
- Directly Connected: Networks physically attached to active interfaces.
- Static Routes: Manually configured paths (best for small networks).
- Dynamic Routes: Paths learned automatically via protocols like OSPF or BGP.
Packet Forwarding Process
- De-encapsulation: Router strips the L2 header to see the L3 IP packet.
- Path Lookup: Router checks the Destination IP against its Routing Table.
- Longest Match: If multiple routes exist, the most specific subnet mask wins.
- Re-encapsulation: Packets are wrapped in a new L2 frame for the exit interface.
- Forwarding: The frame is sent out to the next hop.
Router# show ip route C 192.168.1.0/24 is directly connected, Gi0/0 L 192.168.1.1/32 is directly connected, Gi0/0 S 0.0.0.0/0 [1/0] via 10.0.0.1
Key Takeaway
Switches connect devices within a single subnet; Routers bridge the gaps between subnets.