- [Instructor] The route selection process is actually
pretty straightforward, even if it seems
like magic at first.
Each time a packet will be forwarded by a router,
some form of lookup is performed
on where to send it.
This destination routing is performed
by looking at the route table,
and determining what the best path is.
In many environments, there is only a single route
for a destination, but quite often in my networks
there are multiple possible routes a given subnet can match.
This is almost always true on my networks
with multiple internet connections.
The very first thing a router looks at
is the specificity of a route.
Take this route table example.
I've got a packet destined to host 10.20.30.129
that I'm sending to this router.
So which route is matched and used?
First, looking at the table, it has a default route,
which means everything is matched there,
but is there a better route?
The next route is 10/8, which this route does fall into.
The 10/8 subnet basically says anything
that begins with 10, which this packet does.
The next entry also matches,
though it's a /16, which means it's a more specific route.
It's more specific because a /8 subnet is
over 16 million host addresses,
while a /16 is just over 65,000 hosts.
Thus, we are working with a smaller pool
of addressing, more specific.
Moving down the list, I see that 10.20.30.129
also matches the even more specific subnet
of 10.20.30/24, which is 256 hosts.
Ultimately, the very last entry will be used,
10.20.30.128/25, because the address falls
under it also, and is the most specific,
with only 128 host addresses possible.
So, ultimately the next top route
that the packet will be sent to is 192.168.3.1.
What if the exact same route is learned
from multiple methods?
Say I have a static route for 10.20.30.128/25,
and I'm also learning that exact same route via OSPF.
Which route is installed into the routing table?
In this instance, a static route with no modifications
would win and be installed in the routing table.
That comes down to administrative distance.
This chart shows the default administrative distance
of every method a Cisco router can use to learn routes.
If the exact same destination and mask combo is learned
from disparate methods, then the method
with the lowest administrative distance wins
and will be installed into the routing table.
There can be some exceptions,
like if the next top interface of a static route is down,
then it won't be eligible.
Static routes require the next top interface
to be up, up, though the addition
of the permanent keyword will go ahead
and install the route.
AD manipulation can be used to change this behavior.
Route selection can be tricky,
just keep in mind that the most specific route always wins.