BGP Weight Attribute

Topology


Objectives
Use BGP attribute to influence the route selection in BGP. Currently Router R1/R1 running iBGP .Between R1-R3 & R2-R4 ebgp is used. Within ISP we have used Full iBGP mesh ( of course we could have used RR).Connect the network as shown in topology.

Currently R5 learning routes 100.100.100.1/2/3 from both R1 & R2.Whereas R1 learning these routes from ebgp neighbor R3 and R2 learning from R4.

So currently 100.100.100.1/2/3 prefixes are learning via both R1 and R2 from ebgp neighbor R3 and R4.
Now lets make R1 as the primary router to reach at prefixes 100.100.100.1/2/3 so we will add weight 300 for all the routes learned via R1 ebgp neighbor.

On R2 we will make weight 300 for all the routes that learned via R1 on R2.So that R2 will point towards R1 to reach 100.100.100.1/2/3 and R1 will reach to it via its ebgp neighbor.

Now we have configured the weight at 300 from all the routes received by 10.10.10.2. Let’s verify it

Now remember weight is local to router and are not advertised to other router. Hence this weight won’t go automatically to R2 , we have to defined on R2 that for all routes coming from R1 set weight as 300 just we did for R1.We can defined weight in two ways.
Method 1 using neighbor command

So now we are learning all routes 100.100.100.1/2/3 via R1 and for R2 towards R4 we are not learning these as best routes from R4.

Let’s do trace route from R2 to100.100.100.1, which is going via R1So currently all traffic for 100.100.100.1/2/3 will go via R1 , and on R2 also the best routes is via R1
Method 2 using route map.
We can also implement the same using route map, and set weight statement under route map.
By using route map we are having choice to set the weight for particular prefixes as desired.
Let set the weight of 400 for prefix 100.100.100.2 on R1 towards neighbor R3.

Now lets see the weight.

Summary:

  • It is cisco proprietary and first attribute in bgp path selection.
  • BGP weight attribute is local to router, it will not travel within/outside AS , it will not advertised to any iBGP/eBGP neighbor
  • For all directly injected routes in BGP their weight is 32768 , For all learned routes in BGP the weight is 0
  • BGP Weight attributes can be changed either using neighbor command or route map.