IP Routing
Learn how hosts and routers choose next hops, apply longest-prefix matching, and use static or dynamic routes.
Routing is the process of selecting where an IP packet should go next. A host uses its local routing table to decide whether a destination is on-link or should be sent to a router. Routers examine destination prefixes and forward packets toward a next hop; they do not normally know the application’s full purpose.
Routing table and longest prefix
A route commonly contains a destination prefix, next hop or outgoing interface, and selection information such as a metric. When several routes match a destination, IP forwarding uses the most specific matching prefix (longest-prefix match). A default route (0.0.0.0/0 for IPv4 or ::/0 for IPv6) is the fallback when no more-specific route matches.
For example, a laptop sends traffic for a remote network to its default gateway. That gateway looks up the destination, chooses a next hop, and forwards the packet. Each router repeats the lookup until the packet reaches its destination network or a route is unavailable.
Static and dynamic routes
A static route is configured by an administrator. It is predictable and can suit a small, stable network, but it does not automatically adapt when a path fails. Dynamic routing protocols exchange reachability information and recalculate paths. OSPF is commonly used within an organization’s routing domain; BGP exchanges routes between autonomous systems and is also used in some larger private designs.
Route exchange and packet forwarding are related but distinct: a protocol can learn a route, while the forwarding table determines what a router does with a packet now. A valid route also does not grant application access; firewall rules and service policy remain separate.
Diagnose the path
Read route state before making changes:
ip route
ip route get 192.0.2.10
On Windows, route print displays the local route table and tracert shows responding hops where the network permits it. Compare the source and destination prefixes, next hop, interface, and return path. A missing return route, a more-specific unexpected prefix, or a filtering rule can make one-way connectivity look like a routing failure.
IPv4 routers reduce the packet’s TTL as it is forwarded; IPv6 uses a Hop Limit. These fields prevent packets from circulating indefinitely. Traceroute tools use their expiration to infer hops, but firewalls may block or rate-limit the replies.
Security and reliability
Use route filters and peer authentication where supported, limit who can change routing policy, and monitor unexpected route changes. A route can direct traffic but does not encrypt it. Redundant paths improve availability only when failover, route preference, and return traffic have been tested.
Practice
Draw two LANs connected by a router. Give each LAN a non-overlapping prefix, configure the conceptual default gateway for a host, and trace the next hop to the other LAN. Then remove one route and explain which device can detect the missing path.
Trusted references
- RFC 1812: Requirements for IP Version 4 Routers describes IPv4 router behavior.
- RFC 4632: Classless Inter-domain Routing explains prefix-based addressing and aggregation.
- RFC 4271: Border Gateway Protocol 4 specifies BGP route exchange between autonomous systems.