Weight versus local preference. When would you use each?
Show the answer
Say this first
Both steer outbound traffic and both prefer the higher value. Weight is Cisco-only, local to one router, default 0 (32768 for routes it originates) and never advertised. LOCAL_PREF is a standard attribute, default 100, carried to every iBGP peer, so the whole AS agrees on an exit. I use weight for a quick override on one router and local preference for AS-wide policy such as "ISP1 is primary".
Go deeper
Local preference across two edge routers
R1 peers with ISP1, R2 with ISP2, and R1 and R2 run iBGP. R1 sets LOCAL_PREF 200 on everything from ISP1:
route-map ISP1-IN permit 10
set local-preference 200
!
router bgp 64500
neighbor 192.0.2.1 route-map ISP1-IN inThen clear ip bgp 192.0.2.1 soft in applies it. On R2:
R2# show ip bgp | begin Network
Network Next Hop Metric LocPrf Weight Path
*>i 0.0.0.0 10.255.0.1 0 200 0 64496 i
* 198.51.100.1 0 0 64497 iR2 prefers the iBGP path through R1 over its own eBGP path. eBGP over iBGP is step 7; local preference is step 2 and decides first.
Why weight would not do this
Setting weight on R1 changes only R1's choice. R2 would still prefer its own eBGP path to ISP2, and traffic would leave by whichever router it reached first.
Changing the default
bgp default local-preference 150 changes the value given to routes without one, for the whole router.
They will ask next
One path has the higher weight, the other the higher local preference. Which wins?
The higher weight. Weight is step 1.
Can local preference influence traffic coming in to my AS?
No. It never leaves your AS. Inbound needs AS path prepending, MED, provider communities or more specific prefixes.
Traps
- Thinking local preference is sent to the ISP.
- Using weight for a policy that must hold across several edge routers.