Two exits, one decision. Local preference is how a whole AS agrees on which door to use, and it is the tool you will reach for most often.
Advanced · 9 min read
You'll learn to explain LOCAL_PREF, set it with a route map to make one ISP primary, and read it in show ip bgp on both routers.
What LOCAL_PREF is
LOCAL_PREF is a well-known discretionary attribute that tells every router in one AS how much the AS prefers a route. The default is 100 and the highest value wins. It is compared after weight and before AS path length, so it overrides how far away a destination is.
It exists only inside an AS. The router that receives a route from an eBGP neighbour sets the value, iBGP passes it unchanged to the other routers, and it is stripped when a route leaves the AS.
Local preference chooses the exit for the whole AS
On small screens, swipe sideways or focus the diagram and use the arrow keys.
LOCAL_PREF travels inside the AS, so one setting on R1 steers R2 as well. Weight would only have changed R1.
Why it solves what weight cannot
Weight is private to one router. Local preference rides inside the iBGP update, so every router learns the same number and reaches the same conclusion. That is why it is the standard way to say ISP A is primary and ISP B is the backup.
Weight stays on one router, local preference travels
On small screens, swipe sideways or focus the diagram and use the arrow keys.
Weight is Cisco-specific, local to the router and never advertised. Local preference is part of the BGP update inside the AS. Use weight for a single-router exception and local preference for an AS-wide decision.
Setting local preference
Set it on the router that receives the route from the neighbour, with an inbound route map. The route map can match everything, or only some prefixes.
route-map ISPA-IN permit 10
set local-preference 200
!
router bgp 64500
address-family ipv4 unicast
neighbor 192.0.2.1 route-map ISPA-IN in
end
clear ip bgp 192.0.2.1 soft in
R1. Every route from ISP A is stored with local preference 200 and sent to R2 with that value. ISP B routes keep the default 100, so the whole AS leaves through ISP A while it is up.
router bgp 64500
bgp default local-preference 150
Sets the default for routes that no route map has changed. Use it when you want a whole router to prefer or avoid its own external paths.
How the value spreads
On small screens, swipe sideways or focus the diagram and use the arrow keys.
Both routers end up comparing the same number.
Different exits for different prefixes
Match prefixes in the route map to split traffic between providers. Prefixes that ISP A reaches better get 200 from ISP A, and prefixes that ISP B reaches better get 200 from ISP B. Each link carries its share and each is the backup for the other.
ip prefix-list VIA-A seq 5 permit 203.0.113.0/24
ip prefix-list VIA-B seq 5 permit 192.0.2.128/25
!
route-map ISPA-IN permit 10
match ip address prefix-list VIA-A
set local-preference 200
route-map ISPA-IN permit 20
!
route-map ISPB-IN permit 10
match ip address prefix-list VIA-B
set local-preference 200
route-map ISPB-IN permit 20
R1 and R2. Each route map raises the preference for its own prefix list and passes everything else at the default 100.
Reading it on both routers
Illustrative Cisco IOS XE output written for this lesson, not a router capture
R2#show ip bgp 203.0.113.0
BGP routing table entry for 203.0.113.0/24, version 11
Paths: (2 available, best #2, table default)
64502
192.0.2.5 from 192.0.2.5 (12.12.12.12)
Origin IGP, metric 0, localpref 100, valid, external
64501
10.255.0.1 from 10.255.0.1 (1.1.1.1)
Origin IGP, metric 0, localpref 200, valid, internal, best
R2 has its own external path through ISP B, but chooses the iBGP path from R1 because localpref 200 beats 100. Local preference is compared before the rule that prefers eBGP over iBGP.
How a Cisco router chooses one best path
On small screens, swipe sideways or focus the diagram and use the arrow keys.
The comparison stops at the first step where the paths differ. Later steps are never reached for that prefix.
Mistakes to avoid
Common local preference mistakes
On small screens, swipe sideways or focus the diagram and use the arrow keys.
Check these in order before changing the value.
Splitting inbound traffic by prefix
On small screens, swipe sideways or focus the diagram and use the arrow keys.
Each link carries one prefix as the preferred path and the other as the backup. Both prefixes stay reachable through both ISPs, so a failure moves traffic automatically.
Check your understanding
Predict · scenario 1
R1 sets local preference 200 on routes from ISP A. Which routers use that value?
Predict · scenario 2
R2 has an eBGP path with localpref 100 and an iBGP path from R1 with localpref 200. Which does R2 use?
Predict · scenario 3
Which statement about local preference is correct?
FAQ
What is the default local preference?
100 on Cisco IOS XE. The highest value wins.
Is local preference sent to other autonomous systems?
No. It is carried only in iBGP updates. It is removed when a route is sent to an eBGP neighbour.
Can local preference change how others reach me?
No. It controls how your AS sends traffic out. Inbound traffic is influenced with prepending, MED and more-specific prefixes.