Sunday, December 2, 2018

CCIE SPv4 MPLS Inter AS Option A BGP VRF Aware Traffic Engineering - Weight

In this post we will take a look at the BGP attribute Weight. It's Cisco Proprietary and for the most part, I am not a fan of using the command. I have only used it a couple times in production to influence traffic locally, which is the only thing this command can do. The reason it wasn't the first topic is because Weight is automatically tied to any locally originated routes, 32768 specifically which can be modified. We'll modify the weight on a specific network statement to see how it gets applied. Weight can also be used to steer traffic traversing through a router out a given neighbor as well, applied inbound with a route-map. This is the common use for it but since it can also be applied to a network statement to change the default weight, that's what we'll take a look at here.

router bgp 65001
 address-family ipv4 vrf BGP
  network 1.1.1.1 mask 255.255.255.255
  network 172.16.0.0 mask 255.255.255.0
  network 172.16.1.0 mask 255.255.255.0
  network 172.16.2.0 mask 255.255.255.0

First thing we need to do is add a couple loopbacks, place them in the VRF and then use network statements to advertise them.

IOSV1(config-router-af)#do sh bgp vrf BGP
BGP table version is 18, local router ID is 100.1.1.10
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
              x best-external, a additional-path, c RIB-compressed, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
Route Distinguisher: 1:1 (default for vrf BGP)
 *>  1.1.1.1/32       0.0.0.0                  0         32768 i
 *>  3.3.3.3/32       20.1.1.1                               0 100 65003 i
 *>  7.7.7.7/32       20.1.1.1                               0 100 200 65007 i
 *>  9.9.9.9/32       20.1.1.1                               0 100 200 65009 i
 *>  10.10.10.10/32   20.1.1.1                               0 100 200 65010 i
 *>  172.16.0.0/24    0.0.0.0                  0         32768 i
 *>  172.16.1.0/24    0.0.0.0                  0         32768 i
 *>  172.16.2.0/24    0.0.0.0                  0         32768 i

We can see the new routes being advertised into BGP.

route-map RM_WGT_40000 permit 10
 set weight 40000
!
router bgp 65001
 address-family ipv4 vrf BGP
  network 172.16.2.0 mask 255.255.255.0 route-map RM_WGT_40000

To change the weight, a route-map needs to set the weight with a set command. Then the route map is applied to the network statement.

IOSV1(config-router-af)#do sh bgp vrf BGP                                 
BGP table version is 19, local router ID is 100.1.1.10
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
              x best-external, a additional-path, c RIB-compressed, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
Route Distinguisher: 1:1 (default for vrf BGP)
 *>  1.1.1.1/32       0.0.0.0                  0         32768 i
 *>  172.16.0.0/24    0.0.0.0                  0         32768 i
 *>  172.16.1.0/24    0.0.0.0                  0         32768 i
 *>  172.16.2.0/24    0.0.0.0                  0         40000 i

Now that the route-map has been applied and BGP was re-synced, we can see the weight applied to the network we advertised.

The other way to apply Weight to directly to the neighbor via the "weight" command or applying a route-map to the neighbor inbound. 

IOSv2(config-if)#do sh bgp vrf BGP
BGP table version is 10, local router ID is 100.2.4.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
              x best-external, a additional-path, c RIB-compressed, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
Route Distinguisher: 1:1 (default for vrf BGP)
 *   1.1.1.1/32       20.2.4.4                               0 100 65001 i
 *>                   20.1.2.1                               0 100 65001 i
 *>  2.2.2.2/32       0.0.0.0                  0         32768 i
 *   3.3.3.3/32       20.2.4.4                               0 100 65003 i
 *>                   20.1.2.1                               0 100 65003 i
 *   7.7.7.7/32       20.2.4.4                               0 100 200 65007 i
 *>                   20.1.2.1                               0 100 200 65007 i
 *   9.9.9.9/32       20.2.4.4                               0 100 200 65009 i
 *>                   20.1.2.1                               0 100 200 65009 i
 *   10.10.10.10/32   20.2.4.4                               0 100 200 65010 i
 *>                   20.1.2.1                               0 100 200 65010 i
 *   172.16.0.0/24    20.2.4.4                               0 100 65001 i
 *>                   20.1.2.1                               0 100 65001 i
     Network          Next Hop            Metric LocPrf Weight Path
 *   172.16.1.0/24    20.2.4.4                               0 100 65001 i
 *>                   20.1.2.1                               0 100 65001 i
 *   172.16.2.0/24    20.2.4.4                               0 100 65001 i

 *>                   20.1.2.1                               0 100 65001 i

router bgp 65002
 bgp log-neighbor-changes
 !
 address-family ipv4 vrf BGP
  network 2.2.2.2 mask 255.255.255.255
  neighbor 20.1.2.1 remote-as 100
  neighbor 20.1.2.1 activate
  neighbor 20.1.2.1 weight 100
  neighbor 20.2.4.4 remote-as 100
  neighbor 20.2.4.4 activate
  neighbor 20.2.4.4 weight 400

 exit-address-family

IOSv2(config-router-af)#do sh bgp vrf BGP           
BGP table version is 26, local router ID is 100.2.4.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
              x best-external, a additional-path, c RIB-compressed, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
Route Distinguisher: 1:1 (default for vrf BGP)
 *>  1.1.1.1/32       20.2.4.4                             400 100 65001 i
 *                    20.1.2.1                             100 100 65001 i
 *>  2.2.2.2/32       0.0.0.0                  0         32768 i
 *>  3.3.3.3/32       20.2.4.4                             400 100 65003 i
 *                    20.1.2.1                             100 100 65003 i
 *>  7.7.7.7/32       20.2.4.4                             400 100 200 65007 i
 *                    20.1.2.1                             100 100 200 65007 i
 *>  9.9.9.9/32       20.2.4.4                             400 100 200 65009 i
 *                    20.1.2.1                             100 100 200 65009 i
 *>  10.10.10.10/32   20.2.4.4                             400 100 200 65010 i
 *                    20.1.2.1                             100 100 200 65010 i
 *>  172.16.0.0/24    20.2.4.4                             400 100 65001 i
 *                    20.1.2.1                             100 100 65001 i
     Network          Next Hop            Metric LocPrf Weight Path
 *>  172.16.1.0/24    20.2.4.4                             400 100 65001 i
 *                    20.1.2.1                             100 100 65001 i
 *>  172.16.2.0/24    20.2.4.4                             400 100 65001 i

 *                    20.1.2.1                             100 100 65001 i

We can selectively change the weight for a specific prefix and set the weight for all other routes to different weight values.

ip prefix-list R9 seq 5 permit 9.9.9.9/32
!
route-map RM_WGHT permit 10
 match ip address prefix-list R9
 set weight 900
route-map RM_WGHT permit 20

 set weight 100
!
router bgp 65002
 bgp log-neighbor-changes
 !
 address-family ipv4 vrf BGP

  neighbor 20.1.2.1 route-map RM_WGHT in

IOSv2(config-route-map)#do sh bgp vrf BGP
BGP table version is 27, local router ID is 100.2.4.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
              r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
              x best-external, a additional-path, c RIB-compressed, 
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

     Network          Next Hop            Metric LocPrf Weight Path
Route Distinguisher: 1:1 (default for vrf BGP)
 *>  1.1.1.1/32       20.2.4.4                             400 100 65001 i
 *                    20.1.2.1                             100 100 65001 i
 *>  2.2.2.2/32       0.0.0.0                  0         32768 i
 *>  3.3.3.3/32       20.2.4.4                             400 100 65003 i
 *                    20.1.2.1                             100 100 65003 i
 *>  7.7.7.7/32       20.2.4.4                             400 100 200 65007 i
 *                    20.1.2.1                             100 100 200 65007 i
 *   9.9.9.9/32       20.2.4.4                             400 100 200 65009 i
 *>                   20.1.2.1                             900 100 200 65009 i
 *>  10.10.10.10/32   20.2.4.4                             400 100 200 65010 i
 *                    20.1.2.1                             100 100 200 65010 i
 *>  172.16.0.0/24    20.2.4.4                             400 100 65001 i
 *                    20.1.2.1                             100 100 65001 i
     Network          Next Hop            Metric LocPrf Weight Path
 *>  172.16.1.0/24    20.2.4.4                             400 100 65001 i
 *                    20.1.2.1                             100 100 65001 i
 *>  172.16.2.0/24    20.2.4.4                             400 100 65001 i

 *                    20.1.2.1                             100 100 65001 i

With the route-map applied, we can see that the prefix 9.9.9.9/32 has a weight of 900 pointing towards CSR1. Let's test this out via traceroute to see if the paths do take the appropriate paths.

IOSv2#traceroute vrf BGP 7.7.7.7 so lo0 num
Type escape sequence to abort.
Tracing the route to 7.7.7.7
VRF info: (vrf in name/id, vrf out name/id)
  1 20.2.4.4 14 msec 4 msec 5 msec
  2 10.4.12.12 [MPLS: Labels 24009/82 Exp 0] 24 msec 27 msec 25 msec
  3 10.5.12.5 [MPLS: Labels 16/82 Exp 0] 21 msec 23 msec 23 msec
  4 10.5.11.11 [MPLS: Labels 24009/82 Exp 0] 26 msec 70 msec 53 msec
  5 20.2.14.2 [MPLS: Label 82 Exp 0] 24 msec 17 msec 20 msec
  6 20.2.14.14 28 msec 26 msec 43 msec
  7 10.11.14.11 [MPLS: Labels 27/38 Exp 0] 61 msec 52 msec 74 msec
  8 10.11.10.10 [MPLS: Labels 24007/38 Exp 0] 52 msec 56 msec 50 msec
  9 20.7.12.12 [MPLS: Label 38 Exp 0] 60 msec 46 msec 39 msec

 10 20.7.12.7 76 msec *  79 msec


IOSv2#traceroute vrf BGP 9.9.9.9 so lo0 num
Type escape sequence to abort.
Tracing the route to 9.9.9.9
VRF info: (vrf in name/id, vrf out name/id)
  1 20.1.2.1 13 msec 3 msec 3 msec
  2 10.1.13.13 [MPLS: Labels 24006/83 Exp 0] 33 msec 23 msec 31 msec
  3 10.13.3.3 [MPLS: Labels 28/83 Exp 0] 44 msec 37 msec 35 msec
  4 10.3.11.11 [MPLS: Labels 24009/83 Exp 0] 25 msec 34 msec 22 msec
  5 20.2.14.2 [MPLS: Label 83 Exp 0] 23 msec 23 msec 21 msec
  6 20.2.14.14 27 msec 30 msec 36 msec
  7 10.11.14.11 [MPLS: Labels 17/25 Exp 0] 48 msec 44 msec 48 msec
  8 10.11.10.10 [MPLS: Labels 24000/25 Exp 0] 119 msec 71 msec 47 msec
  9 20.9.10.10 [MPLS: Label 25 Exp 0] 70 msec 68 msec 59 msec

 10 20.9.10.9 54 msec *  123 msec

We can see that the path towards 7.7.7.7 goes via CSR4 and 9.9.9.9 goes via CSR1.

Thanks for stopping by!
Rob Riker, CCIE #50693

No comments:

Post a Comment