Saturday, 16 June 2012

BGP Attributes: Weight

BGP Attributes: Weight

·         Weight is Cisco proprietary attribute
·         The weight is assigned locally to the router.
·         Higher value is preferred.
·         A weight can be a number from 0 to 65535.
·         Paths that the router originates have a weight 32768 by default, and other paths have a weight of 0.
·         Weight is used to affect the traffic that is leaving your AS.

     R4----------------R2---------------R1--------------R3

·         R2: Ser1/0 – 100.1.24.2 ßà R4: Ser1/0 – 100.1.24.4
·         R2: Ser1/1 – 10.1.12.2 ßà R1: Ser1/1 – 10.1.12.1
·         R1: Ser1/0 – 100.1.13.1 ßà R3: Ser1/0 – 100.1.13.3

·         AS 100: R1 & R2
·         AS 300: R3
·         AS 400: R4

·         iBGP between R1 & R2
·         eBGP between R2 and R4
·         eBGP between R1 and R3
·         Created a loopback 34.34.34.34/32 on R3 and R4 and advertised into BGP.
·         R1’s and R2’s loopbacks are also advertised into BGP.
·         Let’s see how to use Weight in this scenario

BGP Configs:

R3(config-router)#do show run | begin router bgp 300
router bgp 300
 no synchronization
 bgp router-id 3.3.3.3
 bgp log-neighbor-changes
 network 34.34.34.34 mask 255.255.255.255
 neighbor 100.1.13.1 remote-as 100
 no auto-summary
!

R4(config-router)#do show run | begin router bgp 400
router bgp 400
 no synchronization
 bgp router-id 4.4.4.4
 bgp log-neighbor-changes
 network 34.34.34.34 mask 255.255.255.255
 neighbor 100.1.24.2 remote-as 100
 no auto-summary
!
R1(config-router)#do show run | begin router bgp 100
router bgp 100
 no synchronization
 bgp router-id 1.1.1.1
 bgp log-neighbor-changes
 network 1.1.1.1 mask 255.255.255.255
 neighbor 2.2.2.2 remote-as 100
 neighbor 2.2.2.2 update-source Loopback0
 neighbor 2.2.2.2 next-hop-self
 neighbor 100.1.13.3 remote-as 300
 no auto-summary
!

R2(config-router)#do show run | begin router bgp 100
router bgp 100
 no synchronization
 bgp router-id 2.2.2.2
 bgp log-neighbor-changes
 network 2.2.2.2 mask 255.255.255.255
 neighbor 1.1.1.1 remote-as 100
 neighbor 1.1.1.1 update-source Loopback0
 neighbor 1.1.1.1 next-hop-self
 neighbor 100.1.24.4 remote-as 400
 no auto-summary
!

R3#show ip bgp sum
BGP router identifier 3.3.3.3, local AS number 300
BGP table version is 4, main routing table version 4
3 network entries using 351 bytes of memory
3 path entries using 156 bytes of memory
4/3 BGP path/bestpath attribute entries using 496 bytes of memory
1 BGP AS-PATH entries using 24 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 1027 total bytes of memory
BGP activity 3/0 prefixes, 3/0 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
100.1.13.1      4   100     944     943        4    0    0 15:39:22        2
R3#

R4#show ip bgp sum
BGP router identifier 4.4.4.4, local AS number 400
BGP table version is 6, main routing table version 6
3 network entries using 351 bytes of memory
3 path entries using 156 bytes of memory
4/3 BGP path/bestpath attribute entries using 496 bytes of memory
1 BGP AS-PATH entries using 24 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 1027 total bytes of memory
BGP activity 3/0 prefixes, 4/1 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
100.1.24.2      4   100     946     943        6    0    0 15:39:32        2
R4#

R1#show ip bgp sum
BGP router identifier 1.1.1.1, local AS number 100
BGP table version is 5, main routing table version 5
3 network entries using 351 bytes of memory
4 path entries using 208 bytes of memory
5/3 BGP path/bestpath attribute entries using 620 bytes of memory
2 BGP AS-PATH entries using 48 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 1227 total bytes of memory
BGP activity 3/0 prefixes, 4/0 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
2.2.2.2         4   100     945     945        5    0    0 15:40:07        2
100.1.13.3      4   300     943     944        5    0    0 15:39:42        1
R1#

R2#show ip bgp sum
BGP router identifier 2.2.2.2, local AS number 100
BGP table version is 6, main routing table version 6
3 network entries using 351 bytes of memory
4 path entries using 208 bytes of memory
5/3 BGP path/bestpath attribute entries using 620 bytes of memory
2 BGP AS-PATH entries using 48 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 1227 total bytes of memory
BGP activity 3/0 prefixes, 4/0 paths, scan interval 60 secs

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
1.1.1.1         4   100     945     945        6    0    0 15:40:08        2
100.1.24.4      4   400     943     946        6    0    0 15:39:31        1
R2#

BGP Table:

R3#show ip bgp
BGP table version is 4, local router ID is 3.3.3.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
*> 1.1.1.1/32       100.1.13.1               0             0 100 i
*> 2.2.2.2/32       100.1.13.1                             0 100 i
*> 34.34.34.34/32   0.0.0.0                  0         32768 i
R3#

R4#show ip bgp
BGP table version is 6, local router ID is 4.4.4.4
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
*> 1.1.1.1/32       100.1.24.2                             0 100 i
*> 2.2.2.2/32       100.1.24.2               0             0 100 i
*> 34.34.34.34/32   0.0.0.0                  0         32768 i
R4#

R1#show ip bgp
BGP table version is 5, local router ID is 1.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
*> 1.1.1.1/32       0.0.0.0                  0         32768 i
r>i2.2.2.2/32       2.2.2.2                  0    100      0 i
* i34.34.34.34/32   2.2.2.2                  0    100      0 400 i
*>                  100.1.13.3               0             0 300 i
R1#

R1#show ip bgp 34.34.34.34
BGP routing table entry for 34.34.34.34/32, version 2
Paths: (2 available, best #2, table Default-IP-Routing-Table)
  Advertised to update-groups:
     2
  400
    2.2.2.2 (metric 65) from 2.2.2.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, valid, internal
  300
    100.1.13.3 from 100.1.13.3 (3.3.3.3)
      Origin IGP, metric 0, localpref 100, valid, external, best
R1#

Observation:

·         R1 is learning 34.34.34.34 from two neighbors.
·         One from eBGP neighbor R3 and another one from an iBGP neighbor R2
·         R1 has chosen the best path to reach 34.34.34.34 through R3
·         This expected because eBGP has AD of 20 and iBGP has an AD of 200

·         R2’s loopback 2.2.2.2/32 has “r” symbol in the front (rib-failure).
·         This means R1 is learning about 2.2.2.2/32 from some other means which has a better (lower) AD
·         R2 has already learnt this route via OSPF which has an AD of 110, so R1 will show this as rib-failure in BGP Table.

R1#show ip route ospf
     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/65] via 10.1.12.2, 16:01:27, Serial1/1
R1#

R2#show ip bgp
BGP table version is 6, local router ID is 2.2.2.2
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
r>i1.1.1.1/32       1.1.1.1                  0    100      0 i
*> 2.2.2.2/32       0.0.0.0                  0         32768 i
*> 34.34.34.34/32   100.1.24.4               0             0 400 i
* i                 1.1.1.1                  0    100      0 300 i
R2#

R2#show ip bgp 34.34.34.34
BGP routing table entry for 34.34.34.34/32, version 3
Paths: (2 available, best #1, table Default-IP-Routing-Table)
  Advertised to update-groups:
     1
  400
    100.1.24.4 from 100.1.24.4 (4.4.4.4)
      Origin IGP, metric 0, localpref 100, valid, external, best
  300
    1.1.1.1 (metric 65) from 1.1.1.1 (1.1.1.1)
      Origin IGP, metric 0, localpref 100, valid, internal
R2#

Observation:

·         R2 is learning 34.34.34.34 from two neighbors.
·         One from eBGP neighbor R4 and another one from an iBGP neighbor R1
·         R2 has chosen the best path to reach 34.34.34.34 through R4
·         This expected because eBGP has AD of 20 and iBGP has an AD of 200

·         R1’s loopback 1.1.1.1/32 has “r” symbol in the front (rib-failure).
·         This means R2 is learning about 1.1.1.1/32 from some other means which has a better (lower) AD
·         R1 has already learnt this route via OSPF which has an AD of 110, so R1 will show this as rib-failure in BGP Table.

R2#show ip route ospf
     1.0.0.0/32 is subnetted, 1 subnets
O       1.1.1.1 [110/65] via 10.1.12.1, 16:03:30, Serial1/1
R2#

·         Now, back to our learning on Weight Attribute.
·         What if R1 ahs to go through R2 to reach the prefix 34.34.34.34 ???
·         We can use Weight attribute to do this.
·         There are many ways to configure Weight
Case – I

R1(config)#router bgp 100
R1(config-router)# neighbor 2.2.2.2 weight 999

R1(config-router)#do show ip bgp
BGP table version is 5, local router ID is 1.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
*> 1.1.1.1/32       0.0.0.0                  0         32768 i
r>i2.2.2.2/32       2.2.2.2                  0    100    999 i
*>i34.34.34.34/32   2.2.2.2                  0    100    999 400 i
*                   100.1.13.3               0             0 300 i
R1(config-router)#

R1#trace 34.34.34.34 source 1.1.1.1

Type escape sequence to abort.
Tracing the route to 34.34.34.34

  1 10.1.12.2 36 msec 76 msec 32 msec
  2 100.1.24.4 48 msec *  64 msec
R1#

Observation:

·         Our configuration is working, now R1 is taking the route through R2 to reach 34.34.34.34
·         Since we configured weight for neighbor R2, Weight 999 has been applied to the all learned routes from R2

Case – II

R1(config)#route-map WEIGHT
R1(config-route-map)#set weight 888
R1(config-route-map)#router bgp 100
R1(config-router)#no neighbor 2.2.2.2 weight 999
R1(config-router)#neighbor 2.2.2.2 route-map WEIGHT in
R1(config-router)#

R1(config-router)#do show ip bgp
BGP table version is 5, local router ID is 1.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
*> 1.1.1.1/32       0.0.0.0                  0         32768 i
r>i2.2.2.2/32       2.2.2.2                  0    100    888 i
*>i34.34.34.34/32   2.2.2.2                  0    100    888 400 i
*                   100.1.13.3               0             0 300 i
R1(config-router)#

R1(config-router)#do trace 34.34.34.34 source 1.1.1.1

Type escape sequence to abort.
Tracing the route to 34.34.34.34

  1 10.1.12.2 32 msec 48 msec 12 msec
  2 100.1.24.4 68 msec *  48 msec
R1(config-router)#

Observation:

·         Our configuration is working, now R1 is taking the route through R2 to reach 34.34.34.34
·         Since we configured weight for neighbor R2, Weight 888 has been applied to the all learned routes from R2

Case - III

R1(config)#ip prefix-list LOOP34 permit 34.34.34.34/32
R1(config)#route-map WEIGHT-777
R1(config-route-map)#match ip address prefix-list LOOP34
R1(config-route-map)#set weight 777
R1(config-route-map)#exit
R1(config)#route-map WEIGHT-777 permit 20
R1(config-route-map)#router bgp 100
R1(config-router)#no neighbor 2.2.2.2 route-map WEIGHT in
R1(config-router)#neighbor 2.2.2.2 route-map WEIGHT-777 in
R1(config-router)#do clear ip bgp *

R1(config-router)#do show ip bgp
BGP table version is 5, local router ID is 1.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
*> 1.1.1.1/32       0.0.0.0                  0         32768 i
r>i2.2.2.2/32       2.2.2.2                  0    100      0 i
*>i34.34.34.34/32   2.2.2.2                  0    100    777 400 i
*                   100.1.13.3               0             0 300 i
R1(config-router)#

Observation:

·         Our configuration is working, now R1 is taking the route through R2 to reach 34.34.34.34
·         Since we configured weight for only 34.34.34.34/32 which is matched by LOOP34, from the neighbor R2, Weight 777 has been applied only to this prefix and it is not applied for the other route from R2 (2.2.2.2/32)

No comments:

Post a Comment