3 IP Connectivity and Routing
Understand how routers select and install routes, configure and troubleshoot static routing and OSPFv2, and provide resilient first-hop gateway service.
Route information and selection
Routers move packets between IP networks by examining each packet’s destination address, selecting the best matching route, and forwarding the packet toward its next hop. Route information can come from directly connected interfaces, manually configured static routes, or dynamic routing protocols. On Cisco IOS, show ip route displays IPv4 routes and show ipv6 route displays IPv6 routes.
Interpreting routes and choosing a path
A routing-table entry commonly identifies the route source, destination prefix, next hop or outgoing interface, , and metric. Common IPv4 route codes include C for connected, L for a local interface address, S for static, and O for . In an entry such as [110/20], 110 is the and 20 is the metric. A metric is a protocol-specific value for comparing routes learned through the same protocol; for , a lower metric is preferred.
When forwarding a packet, the router first finds routes matching the destination, then applies to select the most specific one. This selection happens before is compared, so a less-specific route does not win merely because its source has a lower . For routes to the same prefix from different sources, the lower is preferred. For routes learned through the same protocol, the protocol’s metric is used; equal-cost paths may be used together if supported and configured.
After selecting a route, the router forwards the packet using its next hop and outgoing interface. If no route matches, the packet is dropped unless a default route exists. A default route, 0.0.0.0/0 for IPv4 or ::/0 for IPv6, is the gateway of last resort: it matches destinations for which no more-specific route exists. Cisco IOS displays the active gateway of last resort in the routing-table header when one is installed.
For example, a route-table entry such as O 192.168.20.0/24 [110/20] via 10.0.0.2, 00:00:12, GigabitEthernet0/0 indicates an route with 110 and metric 20, forwarded to next hop 10.0.0.2. The entry S* 0.0.0.0/0 [1/0] via 203.0.113.1 marks a static candidate default route.
Static and backup routes
A is entered by an administrator. It can suit a small, stable network, a specific destination, or a default path toward an upstream router. Static routes do not automatically adapt to topology changes unless suitable tracking or backup behavior is configured.
Cisco IOS supports IPv4 network, default, and host routes, as well as an IPv6 default route. The examples show the destination prefix or address, mask where used, next hop, and—on the floating route—an optional .
A has a higher than the preferred route. For example, an route with the default of 110 is preferred over the example with 200 while the route is available. If that preferred route disappears, the floating route may be installed, provided its next hop is reachable.
When troubleshooting a , check the destination prefix and mask, next-hop reachability, outgoing-interface status, and configured . Use show ip route or show ipv6 route to check whether the route is installed: a configured route is not necessarily active if its next hop cannot be resolved.
Dynamic routing and fundamentals
A Dynamic routing protocol lets routers exchange reachability information and recalculate routes when the topology changes. is a link-state interior gateway protocol: routers exchange link-state information, build a link-state database for their area, and calculate shortest paths using the Shortest Path First algorithm. prefers the lower total cost. Cisco IOS calculates interface cost from bandwidth and a reference bandwidth, so that reference may need adjustment to distinguish modern high-speed links.
OSPFv2 is used for IPv4. In a basic single-area deployment, participating interfaces belong to the same area, commonly area 0; learned routes appear with code O in the IPv4 .
The is a 32-bit identifier written in IPv4-address format. It identifies the router within and is not necessarily assigned to a usable interface. Cisco IOS selects an ID when the process starts: a manually configured ID takes precedence; otherwise, it prefers a loopback address and selects the highest loopback address. If there is no loopback, it selects the highest active interface address. Explicitly configuring a unique router ID makes identification predictable. A changed ID may require restarting the process to take effect.
The process ID in a command such as router 10 is locally significant; neighboring Cisco routers do not need to use the same process ID.
neighbors and configuration
sends Hello packets to discover and maintain neighbors. Routers need compatible interface and area settings to form a neighbor relationship. Common causes of a failed adjacency include a mismatched area, hello or dead intervals, authentication settings, subnet configuration, or network type.
On a broadcast Ethernet segment, routers elect a designated router (DR) and backup designated router (BDR) to reduce redundant exchanges. A point-to-point link does not need a DR/BDR election. On broadcast networks, the highest interface priority wins the DR election; a priority of zero makes a router ineligible. If priorities tie, the highest router ID wins. The election is not preemptive: a higher-priority router that comes online later does not automatically replace the existing DR.
For a basic single-area OSPFv2 configuration, the following example enables process 10, sets the router ID, and matches two local interface networks into area 0. A wildcard mask is the inverse of the subnet mask; for example, 0.0.0.255 corresponds to 255.255.255.0.
The network statements select local interfaces whose addresses match the address-and-wildcard pattern and assign those interfaces to the specified area. They are not simply announcements of arbitrary remote networks. Verify operation with:
show ip neighbor should display expected neighbors; a fully adjacent neighbor commonly has state FULL. If it does not, compare interface addresses and masks, area, timers, network type, and other matching settings on both sides.
First-hop gateway redundancy
Hosts typically have one configured default gateway. If that gateway router or Layer 3 switch fails, hosts may lose off-subnet connectivity even if another router is available on the LAN. A lets multiple Layer 3 devices present a shared virtual gateway address. Hosts use that address as their default gateway, and participating devices designate a forwarder while a backup can take over if the active device fails. This reduces dependence on one physical gateway, but does not by itself guarantee that upstream paths beyond the gateway are healthy.
: A Cisco protocol with active and standby roles. The active device forwards traffic for the group’s virtual IP and virtual MAC. Priority influences the election; preemption must be enabled if a returning higher-priority device should take over from an already-active lower-priority device.
: A standards-based protocol with an active router and backup routers managing a virtual router. The active router forwards packets for the virtual address, and a backup can take over if the active router becomes unavailable.
: A Cisco FHRP that provides gateway redundancy while distributing hosts’ forwarding across multiple gateway devices, rather than relying on only one active forwarder for a group.
When interpreting operational status, identify the virtual gateway address, the device currently forwarding, the backup device or devices, and whether the displayed state indicates a problem. On Cisco IOS, show standby is commonly used to inspect state; commands and output can vary by platform.