Changing the BGP Weight attribute

Written on by admin on. Posted in BGP

When BGP has multiple paths to the same destination it must decide which one to select. The route selection process is based on attributes, where the Weight attribute is the first one that BGP takes into account when deciding which path to choose in order to reach the destination. Weight attribute has local meaning (and it is a Cisco only feature) and it is not transmitted to other routers. Those routes that have a higher weight value are preferred.

In this article I will show how to change the bgp weight attribute for all updates received from a neighbor. To change the weight attribute use next command:

neighbor{ip-addr| peer-group} weight weight-value

Where:

  • ip-addr – is the address of the BGP neighbor
  • peer-group – the name of BGP peer group
  • weight-value – is the weight, which can be between 0 and 65535. Default value for routes received from neighbors is 0, for local routes is 32726

Let us have an example, consider please the scenario below:

BGP-weight-scenario

From the picture you see that WEST router in AS 65520 receives the routes advertised by EAST router in AS 65523 (172.16.0.0/24 and 192.168.100.0/24) over ISP-1 and ISP-2 routers. BGP will choose to reach those routes over ISP-1 or ISP-2. Let’s assume that all configurations are already made and all settings are left default. If so, let’s take a look at the bgp table of WEST router:

WEST#show ip bgp 
BGP table version is 11, local router ID is 10.0.1.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
*  172.16.0.0/24    10.0.1.2                               0 65522 65523 i
*>                  10.0.0.2                               0 65521 65523 i
*  192.168.100.0    10.0.1.2                               0 65522 65523 i
*>                  10.0.0.2                               0 65521 65523 i
WEST#

As you can see, BGP weight attribute is “0” for updates received from neighbors. It chose the path over 10.0.0.2 as the best one (marked with >),¬†most likely because 10.0.0.2 was the first who advertised the routes received from¬†EAST router. The routes to EAST networks over 10.0.0.2 will be put in routing table by BGP which is confirmed by output below (highlighted with red).

WEST#show ip route 
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

     172.16.0.0/24 is subnetted, 1 subnets
B       172.16.0.0 [20/0] via 10.0.0.2, 00:06:51
     10.0.0.0/24 is subnetted, 2 subnets
C       10.0.0.0 is directly connected, FastEthernet0/0
C       10.0.1.0 is directly connected, FastEthernet0/1
B    192.168.100.0/24 [20/0] via 10.0.0.2, 00:06:51
WEST#

Ok, now we’ll change the weight attribute on WEST router for updates received from ISP-2:

WEST(config)#router bgp 65520
WEST(config-router)#neighbor 10.0.1.2 weight 100

Because we changed local router policies we need to make router to generate new inbound updates from stored table.

WEST(config-router)#end
WEST#clear ip bgp * soft in

Time to check! Let’s see again bgp table and routing table

WEST#show ip bgp 
BGP table version is 13, local router ID is 10.0.1.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
*> 172.16.0.0/24    10.0.1.2                             100 65522 65523 i
*                   10.0.0.2                               0 65521 65523 i
*> 192.168.100.0    10.0.1.2                             100 65522 65523 i
*                   10.0.0.2                               0 65521 65523 i
WEST#
WEST#show ip route 
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

     172.16.0.0/24 is subnetted, 1 subnets
B       172.16.0.0 [20/0] via 10.0.1.2, 00:02:19
     10.0.0.0/24 is subnetted, 2 subnets
C       10.0.0.0 is directly connected, FastEthernet0/0
C       10.0.1.0 is directly connected, FastEthernet0/1
B    192.168.100.0/24 [20/0] via 10.0.1.2, 00:02:19
WEST#

Now, the weight for updates received from ISP-2 has changed to 100 which make the routes through ISP-2 (10.0.1.2) be chosen as the best by BGP and are put in the routing table!

Good Luck!

8888 views

Leave a comment


eight + 4 =