How to Configure BGP Weight Attribute

Weight is a Cisco proprietary BGP attribute that can be used to select a certain path. Here’s what you need to know about weight:

  • Weight is the first BGP attribute in the list.
  • Cisco proprietary so you won’t find it on other vendor routers.
  • Weight is not exchanged between BGP routers.
  • Weight is only local on the router.
  • The path with the highest weight is preferred.

Let me give you an example of BGP weight:

BGP Weight Prefer Path

R1 in AS 1 can reach AS 3 through AS 2 or AS 4. If we want to ensure AS 2 is always used as the best path, you can change the weight. In my example, the weight for the path to AS 2 is set to 500 and higher than the weight of 400 for AS 4. Let’s see what this looks like on real Cisco routers. This is the topology that I will use:

Bgp Weight Attribute Lab Topology

Above, we have a simple scenario with two autonomous systems. R2 and R3 both have network 2.2.2.0/24 configured on their loopback0 interface, and I’ll advertise that in BGP.

R1(config)#router bgp 1
R1(config-router)#bgp router-id 1.1.1.1
R1(config-router)#neighbor 192.168.12.2 remote-as 2
R1(config-router)#neighbor 192.168.13.3 remote-as 2
R2(config)#router bgp 2
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#neighbor 192.168.12.1 remote-as 1
R2(config-router)#neighbor 192.168.23.3 remote-as 2
R2(config-router)#network 2.2.2.0 mask 255.255.255.0
R3(config)#router bgp 2
R3(config-router)#bgp router-id 3.3.3.3
R3(config-router)#neighbor 192.168.13.1 remote-as 1
R3(config-router)#neighbor 192.168.23.2 remote-as 2
R3(config-router)#network 2.2.2.0 mask 255.255.255.0

Above you’ll find the configuration for BGP. I configured the manual router ID for a reason. R2 and R3 have the same IP address on the loopback interface, which means they would get the same router ID, and they would be unable to form a BGP neighbor adjacency. Let’s take a detailed look at R1:

R1#show ip bgp 
BGP table version is 2, local router ID is 192.168.13.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
*> 2.2.2.0/24       192.168.12.2             0             0 2 i
*                   192.168.13.3             0             0 2 i

Router R1 decided to use 192.168.12.2 as the next hop. All the BGP attributes are the same, so it came down to the router ID to select a winner.

The default weight for a prefix that the router originates is 32768. You can verify this by taking a look at prefix 2.2.2.0/24 in the BGP table on R2 or R3.

Now let’s change this behavior using the weight attribute…

R1(config)#router bgp 1
R1(config-router)#neighbor 192.168.13.3 weight 500

You can configure weight per neighbor using the weight command. All prefixes from this neighbor will have a weight of 500.

We're Sorry, Full Content Access is for Members Only...

If you like to keep on reading, Become a Member Now! Here is why:

  • Learn any CCNA, CCNP and CCIE R&S Topic. Explained As Simple As Possible.
  • Try for Just $1. The Best Dollar You’ve Ever Spent on Your Cisco Career!
  • Full Access to our 785 Lessons. More Lessons Added Every Week!
  • Content created by Rene Molenaar (CCIE #41726)

1830 Sign Ups in the last 30 days

satisfaction-guaranteed
100% Satisfaction Guaranteed!
You may cancel your monthly membership at any time.
No Questions Asked!

Forum Replies

  1. In AS 2 you have named but nowwhere you have configured jim…you have configured JACK …in the second Diagram consisting of 3 routers you have named them James , jim , john…should i assume jim as Jack?..Excellent explanation by the way …

  2. Rene,
    Great lesson however, I have questions if we have two ISPs and we would like to route traffic out through ISP-1. It means we need to set up a higher weight on the ISP-1 peering with us and setup a lower weight on the second ISP-2?
    How can we make sure traffic goes out ISP-1 and comes back in using ISP-2?
    Thanks

    Hamood

  3. Hi Hamood,

    That’s right, you can use weight to select the path but this is only for the local router. If you want to influence your entire AS then you’ll have to use local preference:

    https://networklessons.com/bgp/how-to-configure-bgp-local-preference-attribute/

    To influence how traffic enters our AS we have a couple of methods, the first one is MED:

    https://networklessons.com/bgp/how-to-configure-bgp-med-attribute/

    This is only useful when you are multihomed to a single ISP. These two methods will help if you are multihomed to different ISPs:

    https://networkl

    ... Continue reading in our forum

  4. Hi Renee,
    Great lesson but I would like to make one suggestion. I find it easier to follow when you name routers R1, R2, R3 instead of using name like Jack, Jon, James etc. I find names harder to keep straight in my head. Just my opinion.

    Thanks for all the cool Lessons.

94 more replies! Ask a question or join the discussion by visiting our Community Forum