Route selection algorithm

Whether static, dynamic, or policy-based routing is used, the algorithm used by the IP layer to select a route from a route table is the same. Route selection occurs in the following order:

  1. If a route exists to the destination address (a host route), it is chosen.
  2. If no host route exists to the destination address, the route chosen depends upon the version of IP being used:
    • For IPv4:
      1. If subnet, network, or supernetwork routes exist to the destination, the route with the most specific network mask (the mask with the most bits on) is chosen.
      2. If the destination is a multicast destination and a multicast default route exists, that route is chosen.
    • For IPv6, if prefix routes exist to the destination, the route with the most specific prefix is chosen.
  3. Default routes are chosen when no other route exists to a destination.

Multiple equal-cost routes are allowed for static, dynamic, and policy-based routing. Table 1 and Multiple equal-cost routes provide additional information about the use of multiple equal-cost routes.

In the absence of policy-based routing, the IP layer routes traffic by searching the main route table for the most specific route known, using the selection order described. If policy-based routing is being used, the IP layer routes traffic according to the policy defined for the traffic. For more information about how the IP layer routes traffic when policy-based routing is being used, see Policy-based routing.