Troubleshooting notes · BGP
BGP ignores local preference: weight is compared first
Local preference says use ISP A, but traffic leaves through ISP B. How the BGP best-path order explains it and how to find the leftover weight. Real output from Cisco IOS XE 17.18.
The symptom
The policy is meant to give the main ISP (A) local preference 200, yet the router picks the backup ISP (B). show ip bgp shows a weight of 100 on the backup ISP's path:
R1# show ip bgp
Network Next Hop Metric LocPrf Weight Path
*> 10.1.1.0/24 0.0.0.0 0 32768 i
* 198.51.100.0 10.0.12.2 0 64510 64500 i
*> 10.0.13.3 100 64520 64500 i
R1# show ip bgp 198.51.100.0
Paths: (2 available, best #2, table default)
64510 64500
10.0.12.2 from 10.0.12.2 (2.2.2.2)
Origin IGP, localpref 100, valid, external
64520 64500
10.0.13.3 from 10.0.13.3 (3.3.3.3)
Origin IGP, localpref 100, weight 100, valid, external, best
R1# show ip bgp neighbors 10.0.13.3 | include oute map
Route map for incoming advertisements is ISP-B-IN
Why it happens
Cisco's best-path selection compares attributes in a fixed order, and the first difference decides:
- next hop reachable
- highest weight (Cisco-only, local to this router)
- highest local preference
- locally originated
- shortest AS path
- lowest origin type, then lowest MED, then eBGP over iBGP, and so on
A route map left over from a test sets weight 100 on ISP B's routes. Weight is compared before local preference, so ISP B wins before local preference is even looked at. The last line of the output shows where it comes from: the inbound route map on that neighbour.
The fix
Remove the route map that sets the weight, then refresh the routes from that neighbour:
R1(config)# router bgp 65001
R1(config-router)# no neighbor 10.0.13.3 route-map ISP-B-IN in
R1(config-router)# end
R1# clear ip bgp 10.0.13.3 soft in
In our tests on IOS XE 17.18, the new attributes took up to a minute to show after the refresh. Wait and check again before you decide the fix didn't work.
Then check the local preference itself
With the weight gone, both paths in this lab still had local preference 100: the route map that sets 200 was applied outbound towards ISP A, where it changes nothing on the routes R1 receives. Local preference is set on routes coming in:
R1(config)# router bgp 65001
R1(config-router)# no neighbor 10.0.12.2 route-map ISP-A-IN out
R1(config-router)# neighbor 10.0.12.2 route-map ISP-A-IN in
R1(config-router)# end
R1# clear ip bgp 10.0.12.2 soft in
Check it
R1# show ip bgp | begin Network
Network Next Hop Metric LocPrf Weight Path
*> 10.1.1.0/24 0.0.0.0 0 32768 i
*> 198.51.100.0 10.0.12.2 200 0 64510 64500 i
* 10.0.13.3 0 64520 64500 i
R1# show ip bgp 198.51.100.0
Paths: (2 available, best #1, table default)
64510 64500
Origin IGP, localpref 200, valid, external, best
64520 64500
Origin IGP, localpref 100, valid, external
R1# traceroute 198.51.100.1 source lo0 numeric
1 10.0.12.2 6 msec 1 msec 0 msec
2 10.0.24.4 3 msec * 2 msec
(backup test: R1 Ethernet0/0 shut)
R1# show ip bgp | begin Network
*> 198.51.100.0 10.0.13.3 0 64520 64500 i
R1# traceroute 198.51.100.1 source lo0 numeric
1 10.0.13.3 2 msec 1 msec 1 msec
2 10.0.34.4 1 msec * 2 msec
ISP A's path now has local preference 200 and is best. With the ISP A link down, the router falls back to ISP B.
Practise this fault
This fault is in ENCOR Lab 16, one of the free labs: a ready-made GNS3 project where you find and fix it yourself, with the tested solution. Get it with 14 more free labs, by email:
We’ll email you the download links and occasional lab tips. Unsubscribe with one click, any time. Your address is never shared.