Another Cisco-only BGP characteristic that can be used to choose a path is weight. What you need to know about weight
- The first BGP attribute on the list is weight.
- This attribute is cisco proprietory
- BGP routers don’t exchange weight attribute.
- The BGP path with highest weight is given preference.
- Weight Attribute is only local on the router.
Let me show you what BGP weight looks like:
R1 in AS 100 can get to AS 300 through either AS 200 or AS 400. You can change the weight to make sure that AS 200 is always chosen as the best path. The weight for the way to AS 200 is set to 500, which is more than the weight of 400 for AS 400. Below is the topology we will use:
Presented above is a straightforward example that involves two autonomous systems . The loopback0 interfaces of R2 and R3 are both configured with the network 20.20.20.0 /24, and we will propagate this information over the BGP protocol.
R1(config)#router bgp 100
R1(config-router)#bgp router-id 1.1.1.1
R1(config-router)#neighbor 192.168.120.2 remote-as 200
R1(config-router)#neighbor 192.168.130.3 remote-as 200
R2(config)#router bgp 200
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#neighbor 192.168.120.1 remote-as 100
R2(config-router)#neighbor 192.168.230.3 remote-as 200
R2(config-router)#network 20.20.20.0 mask 255.255.255.0
R3(config)#router bgp 200
R3(config-router)#bgp router-id 3.3.3.3
R3(config-router)#neighbor 192.168.130.1 remote-as 100
R3(config-router)#neighbor 192.168.230.2 remote-as 200
R3(config-router)#network 20.20.20.0 mask 255.255.255.0
The BGP configuration is shown above. There’s a reason we set the router ID manually. Due to their same IP address on the loopback interface, R2 and R3 are unable to construct a BGP neighbor adjacency and will instead receive the same router ID. Let’s examine R1 in more detail:
R1#show ip bgp
BGP table version is 2, local router ID is 192.168.130.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 20.20.20.0/24 192.168.120.2 0 0 200 i
* 192.168.130.3 0 0 200 i
The next hop for Router R1 was chosen to be 192.168.120.2. Since all of the BGP traits are the same, the router ID was the only thing that could make a difference.
For a prefix that the router starts, the usual weight is 32768. This is true; check the BGP table on R2 or R3 for prefix 20.20.20.0/24 to be sure.
Let’s use the weight attribute to change how this works now…
R1(config)#router bgp 100
R1(config-router)#neighbor 192.168.130.3 weight 500
By utilizing the weight command, you are able to configure the weight for each neighbor. This neighbor’s prefixes will all have a weight of 500 whenever they are used.
R1#clear ip bgp *
Let’s reset BGP to make things go faster in your lab.