BGP · · 4 min read

Manipulating BGP Local Preference for Inbound Path Selection

When your network connects to multiple ISPs or has multiple exit points, you need a way to tell every router in your AS which exit to prefer for specific destinations. That's what LOCAL_PREF does — it's a well-known discretionary attribute carried by iBGP throughout your AS, and it's evaluated at step 2 of the best path algorithm (right after the Cisco-proprietary weight). Higher values are preferred.

How Local Preference Works

Configuration

Set local-pref with an inbound route-map on the eBGP session:

route-map PREFER-ISP-A permit 10
 set local-preference 150
!
router bgp 65001
 neighbor 172.16.0.2 route-map PREFER-ISP-A in

Now all routes from ISP-A (172.16.0.2) get local-pref 150 instead of the default 100. Since R1-HQ's iBGP peer R2-HQ also learns some of these routes from ISP-B (with default local-pref 100), the ISP-A path wins across the entire AS.

Selective Local Preference

More commonly, you want different local-pref values for different prefixes:

ip prefix-list CRITICAL-SERVICES seq 10 permit 100.64.0.0/18
ip prefix-list CRITICAL-SERVICES seq 20 permit 100.64.64.0/18
!
route-map ISP-A-IN permit 10
 match ip address prefix-list CRITICAL-SERVICES
 set local-preference 200
!
route-map ISP-A-IN permit 20
 set local-preference 80
!
router bgp 65001
 neighbor 172.16.0.2 route-map ISP-A-IN in

Critical services route through ISP-A (local-pref 200). Everything else prefers ISP-B (which gets default 100, beating ISP-A's 80).

Common Design Patterns

Primary/Backup ISP

! ISP-A = primary (all traffic)
route-map ISP-A-IN permit 10
 set local-preference 200
!
! ISP-B = backup (only used if ISP-A is down)
route-map ISP-B-IN permit 10
 set local-preference 50
!
router bgp 65001
 neighbor 172.16.0.2 route-map ISP-A-IN in
 neighbor 172.16.0.6 route-map ISP-B-IN in

Load Sharing by Destination

ip prefix-list HALF-A seq 10 permit 0.0.0.0/1
ip prefix-list HALF-B seq 10 permit 128.0.0.0/1
!
! ISP-A preferred for 0.0.0.0/1
route-map ISP-A-IN permit 10
 match ip address prefix-list HALF-A
 set local-preference 200
route-map ISP-A-IN permit 20
 set local-preference 80
!
! ISP-B preferred for 128.0.0.0/1
route-map ISP-B-IN permit 10
 match ip address prefix-list HALF-B
 set local-preference 200
route-map ISP-B-IN permit 20
 set local-preference 80

This splits outbound traffic roughly 50/50 by destination. The /1 split is a common quick-and-dirty approach — for finer control, split by specific high-traffic destinations.

Verification

R1-HQ# show ip bgp 100.64.0.0/18
BGP routing table entry for 100.64.0.0/18, version 22
Paths: (2 available, best #1, table default)
  65010
    172.16.0.2 from 172.16.0.2 (203.0.113.1)
      Origin IGP, metric 0, localpref 200, valid, external, best
  65020 65010
    172.16.0.6 from 172.16.0.6 (198.51.100.1)
      Origin IGP, metric 0, localpref 80, valid, external

Path via ISP-A wins with local-pref 200 vs 80.

! Verify on iBGP peer (R2-HQ) — should see the same local-pref
R2-HQ# show ip bgp 100.64.0.0/18
  ...
    1.1.1.1 from 1.1.1.1 (1.1.1.1)
      Origin IGP, metric 0, localpref 200, valid, internal, best

R2-HQ sees local-pref 200 propagated via iBGP — confirming AS-wide path preference.

Local Preference vs Weight

AspectLocal PreferenceWeight
ScopeEntire AS (via iBGP)Single router only
Best path stepStep 2Step 1 (evaluated first)
Default1000 (learned), 32768 (local)
Higher/Lower winsHigher winsHigher wins
VisibilityAll iBGP peers see itNot advertised
Use caseAS-wide traffic engineeringPer-router override

Use local-pref when you want the entire AS to agree on a path. Use weight when you need one specific router to override the AS-wide decision (see Cisco BGP Weight Attribute).

Troubleshooting

SymptomCauseFix
Local-pref set on border router but iBGP peers still using other pathRoute-map not applied, or soft reset not done after config changeVerify show ip bgp neighbors [ip] | include route-map. Run clear ip bgp [peer] soft in.
Both paths showing same local-pref despite route-mapRoute-map match condition not matching the intended prefixesCheck show route-map [name] and prefix-list hit counts. Test with show ip bgp [prefix].
eBGP peer receiving local-pref valuesThis shouldn't happen — local-pref is stripped at eBGP boundaries by defaultVerify the neighbor is actually eBGP (different AS). If confederation eBGP, local-pref is preserved — this is expected.

Key Takeaways

Read next

© 2025 Ping Labz. All rights reserved.