How to Configure BGP Weight Attribute

Weight is a Cisco proprietary BGP attributes 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 for 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)#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)#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)#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, now 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. 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 651 Lessons. More Lessons Added Every Week!
  • Content created by Rene Molenaar (CCIE #41726)

567 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. 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://networ

    ... Continue reading in our forum

  2. Hello Lee

    Looking a little deeper into the issue, looking at the router configurations, the router IDs of both R2 and R3 are indeed the same as both Lo interfaces are set to 2.2.2.2. So according to BGP route selection process, if the router IDs are the same, then the router will prefer the route with the lowest neighbour IP address. So between R2 and R3, the lowest neighbour IP address is indeed 192.168.12.2, so R2 will be chosen as the path.

    So the following statement in the lesson has to be revised:

    //cdn-forum.networklessons.com/uploads/default/original/1

    ... Continue reading in our forum

  3. Thanks Laz for clarifying that for me and the prompt response.

  4. Hi Rene,
    Thanks for replying me…yes after set the router id in R3 now everything is up and not getting identifier error:smiley:

    R3#sh running-config | include bgp
    router bgp 2
    bgp router-id 1.1.1.1
    bgp log-neighbor-changes
    
    R3#sh ip bgp summary
    BGP router identifier 1.1.1.1, local AS number 2
    BGP table version is 1, main routing table version 1
    2 network entries using 288 bytes of memory
    2 path entries using 160 bytes of memory
    2/0 BGP path/bestpath attribute entries using 272 bytes of memory
    0 BGP route-map cache entries using 0 bytes of memory
    0 BGP filter-li
    ... Continue reading in our forum

  5. Hey Lagapides,

    Thank you so much. This cleared up a lot for me. Especially the “in” and “out” issue.

    Regards

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