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 configured on their loopback0 interface and I’ll advertise that in BGP.

R1(config)#router bgp 1
R1(config-router)#neighbor remote-as 2
R1(config-router)#neighbor remote-as 2
R2(config)#router bgp 2
R2(config-router)#neighbor remote-as 1
R2(config-router)#neighbor remote-as 2
R2(config-router)#network mask
R3(config)#router bgp 2
R3(config-router)#neighbor remote-as 1
R3(config-router)#neighbor remote-as 2
R3(config-router)#network mask

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
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
*>             0             0 2 i
*                      0             0 2 i

Router R1 decided to use 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 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 707 Lessons. More Lessons Added Every Week!
  • Content created by Rene Molenaar (CCIE #41726)

521 Sign Ups in the last 30 days

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

Forum Replies

  1. 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?


  2. 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:

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

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


    ... Continue reading in our forum

  3. 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 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, so R2 will be chosen as the path.

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


    ... Continue reading in our forum

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

  5. 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
    bgp log-neighbor-changes
    R3#sh ip bgp summary
    BGP router identifier, 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

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