Routing & Forwarding
Use longest-prefix match and tell routing decisions from packet forwarding.
Next-hop decisions
A router consults its forwarding table for an IP packet's destination. It selects the most specific matching prefix (longest-prefix match), then sends the packet to an outgoing interface or next-hop router. A default route 0.0.0.0/0 is used only when no more specific route matches.
Routes can be connected, configured manually or learned through routing protocols; a forwarding table applies the chosen routes to individual packets.
TTL prevents endless loops
IPv4's Time to Live field is decreased by routers. If it reaches zero, the router discards the packet and may send an ICMP Time Exceeded message. A forwarding loop therefore cannot persist indefinitely.
Traceroute can use successive TTL or hop-limit values to expose responding routers along a path, though firewalls may hide some hops.
Check your understanding
Which entry wins for 203.0.113.7: 0.0.0.0/0 or 203.0.113.0/24?
