The first step in the BGP route selection process is to prefer a route with the
higher local preference value. The local preference value is simply a numerical
value that a network operator in the local AS can assign to a particular
route. This attribute is purely local, it
does not get transmitted between autonomous systems,
so it is dropped in EBGP route
advertisements. But it allows a local network operator
the ability to explicitly state that one
route should be preferred over the other. Among
routes with equally high local preference values,
BGP prefers routes with shorter AS path length.
The idea is that a path might be better if it traverses a fewer number of
autonomous systems. The third step involves comparison
of multiple routes advertised from the same
autonomous system. The multi-exit discriminator value allows
one AS to specify that one exit
point in the network is more preferred than another. So lower MED values are
preferred, but this step only applies to
compare routes that are advertised from the same
autonomous system. Because the neighboring AS sets the MED value on routes that
it advertises to a neighbor, MED
values are not inherently comparable across routes
advertised from different ASs. Therefore this
step only applies to routes advertised from
the same AS. Fourth, BGP speaking routers
inside an autonomous system will prefer a
BGP route with a shorter IGP path cost to the IGP next up. The idea here is
that if a router inside an autonomous system
learns two routes via IBGP then it wants to
prefer the one that results in the shortest
path the to the exit of the network. This
behavior results in what is called hot potato routing,
where an autonomous system sends traffic to the neigjboring
autonomous system via a path that traverses as
little of its own network as possible. Finally, if
there are multiple routes with the highest possible local
preference, the shortest AS path and the shortest IGP
path, the router uses a tiebreak to pick a
single breaking route. This tiebreaking step is arbitrary. It
might be the most stable, or the route that's
been advertised the longest. But often, to induce determinism,
operators typically prefer that this tie breaking step
is performed based on the route advertisement from the
router with the lowest router ID, which is
typically the neighboring router's IP address. Let's now take
a closer look into local preference, AS path
length, muli-exit discriminator and hot potato routing. Now as
I mentioned the first step in the router
selection process is for routers to prefer routes with
higher local preference values. Now an operator can
actually set the local preference value on incoming
BGP route advertisements to affect which route a
router ultimately selects. Let's see how this works.