Tuesday, 12 May 2020

BGP CHAPTER 17- BGP ATTRIBUTE - WEIGHT


It is Cisco proprietary attribute.

It is local on the router.
 
Used to manipulate outbound traffic.

Range of value for Weight is 0 to 65535.
The default value for weight is 32768 for all routes which are originated by the local router.
The default value for weight is 0 for all routes which are not originated by the local router. 
Always a path with the highest weight will be preferred.



WEIGHT
BGP ATTRIBUTE - WEIGHT


Lets check the Interfaces IP Address and the status 

R1#sh ip  int brief | i up
Serial0                    12.1.1.1        YES manual up                    up
Serial1                    13.1.1.1        YES manual up                    up

R2#sh ip  int brief | i up
Serial0                    12.1.1.2        YES manual up                    up
Serial2                    23.1.1.2        YES manual up                    up
R2#

R3#sh ip  int brief | i up
Serial1                    13.1.1.3        YES manual up                    up
Serial2                    23.1.1.3        YES manual up                    up
R3#

Configuration of eBGP 

R1(config)#router bgp 100
R1(config-router)#neighbor 12.1.1.2 remote-as 200
R1(config-router)#neighbor 13.1.1.3 remote-as 300
R1(config-router)#^Z

R2(config)#router bgp 200
R2(config-router)#neighbor 12.1.1.1 remote-as 100
R2(config-router)#neighbor 23.1.1.3 remote-as 300
R2(config-router)#^Z

R3(config)#router bgp 300
R3(config-router)#neighbor 13.1.1.1 remote-as 100
R3(config-router)#neighbor 23.1.1.2 remote-as 200
R3(config-router)#^Z

R1#sh ip bgp summary
BGP router identifier 13.1.1.1, local AS number 100
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
12.1.1.2        4   200       8       8        1    0    0 00:05:43        0
13.1.1.3        4   300       7       8        1    0    0 00:00:44        0
R1#

R2#sh ip bgp summary
BGP router identifier 23.1.1.2, local AS number 200
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
12.1.1.1        4   100       9       8        1    0    0 00:06:00        0
23.1.1.3        4   300       4       4        1    0    0 00:00:38        0
R2#

R3#sh ip bgp summary
BGP router identifier 23.1.1.3, local AS number 300
BGP table version is 1, main routing table version 1

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
13.1.1.1        4   100       5       5        1    0    0 00:01:19        0
23.1.1.2        4   200       4       4        1    0    0 00:00:57        0

Now lets configure a loopback 0 interface on R3 and advertise same in BGP 

R3(config)#int loopback 0
May  9 08:19:39.059: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up
R3(config-if)#ip address 100.100.100.1 255.255.255.0
R3(config-if)#^Z

R3#sh ip bgp

R3#config
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config)#router bgp 300
R3(config-router)#network 100.100.100.0 mask 255.255.255.0
R3(config-router)#^Z
R3#
May  9 08:21:28.143: %SYS-5-CONFIG_I: Configured from console by console
R3#sh ip bgp
BGP table version is 2, local router ID is 23.1.1.3
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
*> 100.100.100.0/24 0.0.0.0                  0         32768 i


Now lets use Weight attribute to manipulate OUTGOING PATH for R1 for network 100.100.100.0/24

Now 
On R1 we have 2 path to reach 100.100.100.0/24

R1#sh ip  bgp
BGP table version is 2, local router ID is 13.1.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
*  100.100.100.0/24 12.1.1.2                               0 200 300 i
*>                  13.1.1.3                 0             0 300 i
R1#

PATH 1 ===> via R2
PATH 2 ===> via R3 

and PATH 2 is best .

Now lets USE WEIGHT TO MAKE PATH1 THE BEST ROUTE

Currently the weight for the both path is 0

Lets make the weight for PATH 1 as 10 

R1(config)#router bgp 100

R1(config-router)#neighbor 12.1.1.2 weight ?
  <0-65535>  default weight

R1(config-router)#neighbor 12.1.1.2 weight 10
R1(config-router)#^Z

R1#clear ip bgp * soft in
R1#clear ip bgp * soft out
R1#
R1#sh ip bgp
BGP table version is 3, local router ID is 13.1.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
*> 100.100.100.0/24 12.1.1.2                              10 200 300 i
*                   13.1.1.3                 0             0 300 i
R1#

Now see the PATH 1 is best 

Another way of doing this is by using route-map

Lets configure another Loopback on R3

R3(config)#int loopback 1
R3(config-if)#ip address 111.111.111.1 255.255.255.0
R3(config-if)#^Z
R3#
May  9 08:48:33.255: %SYS-5-CONFIG_I: Configured from console by console
R3#config
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config)#router bgp 300
R3(config-router)#network 111.111.111.0 mask 255.255.255.0
R3(config-router)#^Z
R3#

Now lets check on R1 

R1#sh ip bgp
BGP table version is 6, local router ID is 13.1.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
*> 100.100.100.0/24 12.1.1.2                              10 200 300 i
*                   13.1.1.3                 0             0 300 i
* 111.111.111.0/24  13.1.1.3                 0             0 300 i
*>                  12.1.1.2                              10 200 300 i
R1#

For both networks Path 1 ie Path via R2 is best 

But for we want that only for network 100.100.100.0/24 the best path should be via R2

and that can be achieve using route-map

R1#sh run | section bgp
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 neighbor 12.1.1.2 remote-as 200
 neighbor 12.1.1.2 weight 10
 neighbor 13.1.1.3 remote-as 300
 no auto-summary
R1#
R1#
R1#config
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#router bgp 100
R1(config-router)#no neighbor 12.1.1.2 weight 10
R1(config-router)#^Z
R1#
May  9 08:52:50.871: %SYS-5-CONFIG_I: Configured from console by console
R1#clear ip bgp * soft in
R1#clear ip bgp * soft out
R1#sh ip bgp
BGP table version is 8, local router ID is 13.1.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
*  100.100.100.0/24 12.1.1.2                               0 200 300 i
*>                  13.1.1.3                 0             0 300 i
*> 111.111.111.0/24 13.1.1.3                 0             0 300 i
*                   12.1.1.2                               0 200 300 i
R1#

NOW LETS USE ROUTE-MAP

R1(config)#ip access-list standard 10
R1(config-std-nacl)#permit 100.100.100.0 0.0.0.255
R1(config-std-nacl)#^Z
R1#

R1(config)#route-map TECHMAP permit 10
R1(config-route-map)#match ip address 10
R1(config-route-map)#set weight 10
R1(config)#route-map TECHMAP permit 20
R1(config-route-map)#set weight 0
R1(config-route-map)#^Z
R1#

R1#sh ip access-lists
Standard IP access list 10
    10 permit 100.100.100.0, wildcard bits 0.0.0.255
R1#sh route-map
route-map TECHMAP, permit, sequence 10
  Match clauses:
    ip address (access-lists): 10
  Set clauses:
    weight 10
  Policy routing matches: 0 packets, 0 bytes
route-map TECHMAP, permit, sequence 20
  Match clauses:
  Set clauses:
    weight 0
  Policy routing matches: 0 packets, 0 bytes
R1#
R1(config)#router bgp 100
R1(config-router)#neighbor 12.1.1.2 route-map TECHMAP in
R1(config-router)#^Z

R1#sh ip bgp
BGP table version is 23, local router ID is 13.1.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
*> 100.100.100.0/24 12.1.1.2                              10 200 300 i
*                   13.1.1.3                 0             0 300 i
*> 111.111.111.0/24 13.1.1.3                 0             0 300 i
*                   12.1.1.2                               0 200 300 i

Now we can see that only for network 100.100.100.0/24 the best path is via R2




No comments:

Post a Comment