Inter-Domain Routing & BGP

local preference

When several BGP routes reach the same destination, an autonomous system needs a way to say, internally, "we'd rather use this one." Local preference is that knob. It is a number attached to a route inside one AS, and the BGP decision process looks at it FIRST — before AS path length, before anything else. Higher local preference wins. Think of it as the network's own ranking sticker it puts on each incoming route: the route with the highest sticker is the one the whole AS will use to leave for that destination.

The word local is the key. Local preference is shared among the routers WITHIN one AS (carried over iBGP) but is never sent to another AS. So it expresses purely internal, usually economic, preference. A common configuration: as routes come in, an import policy stamps a high local preference on routes learned from customers, a medium one on routes from settlement-free peers, and a low one on routes from paid providers. Because local preference is checked first, this single setting makes the entire AS prefer customer exits over peer exits over provider exits — encoding "earn money first, save money second, spend money last."

Because it overrides AS path length, local preference is the most powerful everyday tool for traffic engineering an AS's OUTBOUND traffic — that is, deciding which way your own packets leave. It does not directly affect how the rest of the world sends traffic TO you (that is harder, involving AS path prepending and MED). And because it is invisible outside the AS, two networks can each have completely different local-preference policies for the same routes without ever conflicting.

Routes to prefix P arrive three ways: via a customer (local preference set to 200), via a peer (150), and via a provider (100). Even though the provider route has the shortest AS path, the AS sends its traffic for P out through the CUSTOMER, because local preference 200 is highest and is checked before AS path length.

Local preference is the first tie-breaker in BGP and overrides AS path length; higher wins, and it never leaves the AS.

Local preference controls only how YOUR traffic exits; it has no effect on inbound traffic and is never visible to other ASes, so it cannot be used to ask the outside world to reach you a certain way.

Also called
LOCAL_PREFlocal-pref區域偏好本地優先權