IPv4 Routing

Functions of a Router

The primary functions of a router are to determine the best path to forward packets based on the information in its routing table, and to forward packets toward their destination.

The router uses its IP routing table to determine which path (route) to use to forward a packet. R1 and R2 will use their respective IP routing tables to first determine the best path, and then forward the packet.

IPv4 Longest Match Example

The primary functions of a router are to determine the best path to forward packets based on the information in its routing table, and to forward packets toward their destination.

The router uses its IP routing table to determine which path (route) to use to forward a packet. R1 and R2 will use their respective IP routing tables to first determine the best path, and then forward the packet.

Build the Routing Table

Directly Connected Networks: Added to the routing table when a local interface is configured with an IP address and subnet mask (prefix length) and is active (up and up).

Remote Networks: Networks that are not directly connected to the router. Routers learn about remote networks in two ways:

  • Static routes– Added to the routing table when a route is manually configured.
  • Dynamic routing protocols– Added to the routing table when routing protocols dynamically learn about the remote network.

Default Route: Specifies a next-hop router to use when the routing table does not contain a specific route that matches the destination IP address. The default route can be entered manually as a static route, or learned automatically from a dynamic routing protocol.

  • A default route has a /0 prefix length. This means that no bits need to match the destination IP address for this route entry to be used. If there are no routes with a match longer than 0 bits, the default route is used to forward the packet. The default route is sometimes referred to as a gateway of last resort.

Packet Forwarding Decision Process

Forward the Packet to a Device on a Directly Connected Network ( IF No match ! )  

Known Destination :Forward the Packet to a Next-Hop Router (IF No Match ! )

Unknown Destination (0.0.0.0) Forward the Packet to a Next-Hop Router (IF No Match ! )

Drop the Packet – No Match in Routing Table

IP Routing Table

A routing table contains a list of routes to known networks (prefixes and prefix lengths). The source of this information is derived from the following:

  • Directly connected networks
  • Static routes
  • Dynamic routing protocols

The source for each route in the routing table is identified by a code. Common codes include the following:

  • L– Identifies the address assigned to a router interface.
  • C– Identifies a directly connected network.
  • S– Identifies a static route created to reach a specific network.
  • O– Identifies a dynamically learned network from another router using the OSPF routing protocol.
  • *– This route is a candidate for a default route.

Routing Table Entries

  • Route source– This identifies how the route was learned.
  • Destination network (prefix and prefix length)– This identifies the address of the remote network.
  • Administrative distance– This identifies the trustworthiness of the route source. Lower values indicate preferred route source.
  • Metric– This identifies the value assigned to reach the remote network. Lower values indicate preferred routes.
  • Next-hop– This identifies the IP address of the next router to which the packet would be forwarded.
  • Route timestamp– This identifies how much time has passed since the route was learned.
  • Exit interface– This identifies the egress interface to use for outgoing packets to reach their final destination.

Directly Connected Networks

  • To learn about any remote networks, the router must have at least one active interface configured with an IP address and subnet mask (prefix length). This is known as a directly connected network or a directly connected route. Routers add a directly connected route to its routing table when an interface is configured with an IP address and is activated.

    • A directly connected network is denoted by a status code of Cin the routing table. The route contains a network prefix and prefix length.
    • The routing table also contains a local route for each of its directly connected networks, indicated by the status code of L.
    For IPv4 local routes the prefix length is /32 and for IPv6 local routes the prefix length is /128

Static Routes in the IP Routing Table

  • Static routing has three primary uses:

    • It provides ease of routing table maintenance in smaller networks that are not expected to grow significantly.
    • It uses a single default route to represent a path to any network that does not have a more specific match with another route in the routing table. Default routes are used to send traffic to any destination beyond the next upstream router.
    • It routes to and from stub networks. A stub network is a network accessed by a single route, and the router has only one neighbor.

Dynamic Routing Protocols

  • Dynamic routing protocols are used by routers to automatically share information about the reachability and status of remote networks.

  • Dynamic routing protocols perform several activities, including network discovery and maintaining routing tables.

Default Route

  • The default route specifies a next-hop router to use when the routing table does not contain a specific route that matches the destination IP address.

  • A default route can be either a static route or learned automatically from a dynamic routing protocol. A default route has an IPv4 route entry of 0.0.0.0/0 or an IPv6 route entry of ::/0. This means that zero or no bits need to match between the destination IP address and the default route.

Static Routing and Dynamic Routing

Dynamic Routing

A routing protocol is a set of processes, algorithms, and messages that are used to exchange routing information and populate the routing table with the choice of best paths. The purpose of dynamic routing protocols includes the following:

    • Discovery of remote networks
    • Maintaining up-to-date routing information
    • Choosing the best path to destination networks
    • Ability to find a new best path if the current path is no longer available

The best path is selected by a routing protocol based on the value or metric it uses to determine the distance to reach a network. A metric is the quantitative value used to measure the distance to a given network. The best path to a network is the path with the lowest metric.

Load Balancing

When a router has two or more paths to a destination with equal cost metrics, then the router forwards the packets using both paths equally. This is called equal cost load balancing.

  • The routing table contains the single destination network, but has multiple exit interfaces, one for each equal cost path. The router forwards packets using the multiple exit interfaces listed in the routing table.
  • If configured correctly, load balancing can increase the effectiveness and performance of the network.
  • Equal cost load balancing is implemented automatically by dynamic routing protocols. It is enabled with static routes when there are multiple static routes to the same destination network using different next-hop routers.

Note: Only EIGRP supports unequal cost load balancing

Static Routing Configuration

IPv4 Next-Hop Static Route
R1(config)# ip route 172.16.1.0 255.255.255.0 172.16.2.2
R1(config)# ip route 192.168.1.0 255.255.255.0 172.16.2.2
R1(config)# ip route 192.168.2.0 255.255.255.0 172.16.2.2

IPv4 Directly Connected Static Route

R1(config)# ip route 172.16.1.0 255.255.255.0  s0/1/0
R1(config)# ip route 192.168.1.0 255.255.255.0  s0/1/0
R1(config)# ip route 192.168.2.0 255.255.255.0  s0/1/0

IPv4 Fully Specified Static Route