Routing protocols (including static routing) may discover different routes to the same destination, but not all routes are optimal. Only one routing protocol at a time determines the optimal route to a destination. To select the optimal route, each routing protocol (including static routing) is assigned a preference (a smaller value indicates a higher preference). When multiple routing information sources coexist, the route discovered by the routing protocol with the highest preference is selected as the optimal route and added to the local routing table.
Routers define external and internal preferences. External preference is manually configured for each routing protocol. Table 1 lists the default external preferences of routing protocols.
Routing Protocol or Route Type |
Default External Preference |
---|---|
Direct |
0 |
OSPF |
10 |
IS-IS |
15 |
Static |
60 |
RIP |
100 |
OSPF ASE |
150 |
OSPF NSSA |
150 |
IBGP |
255 |
EBGP |
255 |
In Table 1, the value 0 indicates direct routes and the value 255 indicates routes learned from unreliable sources. A smaller value indicates a higher preference.
You can manually configure the external preference of all routing protocols except direct routes. The preference for each static route varies.
Internal preferences of routing protocols cannot be manually configured. Table 2 lists the internal preferences of routing protocols.
Routing Protocol or Route Type |
Internal Preference |
---|---|
Direct |
0 |
OSPF |
10 |
IS-IS Level-1 |
15 |
IS-IS Level-2 |
18 |
Static |
60 |
RIP |
100 |
OSPF ASE |
150 |
OSPF NSSA |
150 |
IBGP |
200 |
EBGP |
20 |
During route selection, a router first compares the external preferences of routes. When the same external preference is set for different routing protocols, the router selects the optimal route based on the internal preference. For example, assume that there are two routes to 10.1.1.0/24: a static route and an OSPF route. Both routes have the same external preference: 5. In this case, the router determines the optimal route based on the internal preference listed in Table 2. An OSPF route has an internal preference of 10, and a static route has an internal preference of 60. This indicates that the OSPF route has a higher preference than the static route, so the router selects the OSPF route as the optimal route.
If multiple OSPFv2 or OSPFv3 processes learn routes to the same destination and the external and internal priorities of the routes are the same, the system selects the route with the smallest link cost; if the link costs of the routes are the same, the routes participate in load balancing.
If multiple IS-IS processes learn routes to the same destination and the external and internal priorities of the routes are the same, the system selects the route with the smallest link cost; if the link costs of the routes are the same, the routes participate in load balancing.
If multiple RIP or RIPng processes learn routes to the same destination and the external and internal priorities of the routes are the same, the system selects the route with the smallest link cost; if the link costs of the routes are the same, the routes participate in load balancing.
In addition, policy-based routing (PBR) provides a mechanism for selecting routes based on user-defined policies. It allows switches to forward packets based on users even after routing entries are generated. PBR takes precedence over direct routes, static routes, and routes generated by dynamic routing protocols.