BGP Weight Configuration Example [GNS3 Lab]
What is BGP Weight
- Weight: Weight is a Cisco-defined BGP attribute that is local to a router. The weight attribute is not advertised to neighboring routers. If the router learns about more than one route to the same destination, the route with the highest weight will be preferred.
- BGP Weight path attribute is set by default to:
- 32768 by when the Router locally originates network prefixes.
- 0 for learned routes
Topology
Before manipulating the path via Weight, let’s check which neighbor was originally selected to get to the route 4.4.4.4/32:
R1#sh ip bgp
BGP table version is 2, local router ID is 172.16.30.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
* 4.4.4.4/32 172.16.20.2 0 65552 65554 i
*> 172.16.30.2 0 65553 65554 i
So, the neighbor R3 was selected for route 4.4.4.4/32, let’s dive into the configuration of the BGP weight of router R1.
BGP Weight configuration
router bgp 65551
bgp log-neighbor-changes
neighbor 172.16.20.2 remote-as 65552
neighbor 172.16.20.2 route-map Weight-400 in
neighbor 172.16.30.2 remote-as 65553
neighbor 172.16.30.2 route-map Weight-300 in
route-map Weight-400 permit 10
set weight 400
!
route-map Weight-300 permit 10
set weight 300
Verifications
R1#show ip bgp
BGP table version is 2, local router ID is 172.16.30.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 4.4.4.4/32 172.16.20.2 400 65552 65554 i
* 172.16.30.2 300 65553 65554 i
R1#