Social Icons

Wednesday, May 7, 2014

CCNP ROUTE: 10. Influencing an Enterprise’s Outbound Routes: Influencing BGP Weight

The router’s best path algorithm examines the Weight of competing routes, choosing the route with the bigger Weight.
The Cisco-proprietary Weight settings configured on a single router can influence only that one router because the Weight cannot be communicated to other neighboring BGP routers.
So, to use the Weight, a router must be configured to examine incoming Updates to set the Weight.
The Weight parameter can be set either to particular routes or to specific neighbors.

For this lab, we will consider R1 as the only connection between the enterprise and ISPs 1 and 2 (R2 will be shutdown).
The initial BGP configurations are:

R1:

!
interface Loopback1
 ip address 1.1.1.1 255.255.255.255
!
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 neighbor 101.101.101.101 remote-as 101
 neighbor 101.101.101.101 password ccnp
 neighbor 101.101.101.101 ebgp-multihop 2
 neighbor 101.101.101.101 update-source Loopback1
 neighbor 102.102.102.102 remote-as 102
 neighbor 102.102.102.102 ebgp-multihop 2
 neighbor 102.102.102.102 update-source Loopback1
 no auto-summary
!
ip route 101.101.101.101 255.255.255.255 201.1.1.2
ip route 102.102.102.102 255.255.255.255 202.2.2.2
!

R101:

!
interface Loopback101
 ip address 101.101.101.101 255.255.255.255
!
router bgp 101
 no synchronization
 bgp log-neighbor-changes
 neighbor 1.1.1.1 remote-as 100
 neighbor 1.1.1.1 password ccnp
 neighbor 1.1.1.1 ebgp-multihop 2
 neighbor 1.1.1.1 update-source Loopback101
 neighbor 104.104.104.104 remote-as 104
 neighbor 104.104.104.104 password ccnp
 neighbor 104.104.104.104 ebgp-multihop 2
 neighbor 104.104.104.104 update-source Loopback101
 no auto-summary
!
ip route 1.1.1.1 255.255.255.255 201.1.1.1
ip route 104.104.104.104 255.255.255.255 114.1.1.2
!

R102:

!
interface Loopback102
 ip address 102.102.102.102 255.255.255.255
!
router bgp 102
 no synchronization
 bgp log-neighbor-changes
 neighbor 1.1.1.1 remote-as 100
 neighbor 1.1.1.1 ebgp-multihop 2
 neighbor 1.1.1.1 update-source Loopback102
 neighbor 103.103.103.103 remote-as 103
 neighbor 103.103.103.103 ebgp-multihop 2
 neighbor 103.103.103.103 update-source Loopback102
 no auto-summary
!
ip forward-protocol nd
ip route 1.1.1.1 255.255.255.255 202.2.2.1
ip route 103.103.103.103 255.255.255.255 123.1.1.2
!

R103:

!
interface Loopback103
 ip address 103.103.103.103 255.255.255.255
!
router bgp 103
 no synchronization
 bgp log-neighbor-changes
 neighbor 102.102.102.102 remote-as 102
 neighbor 102.102.102.102 ebgp-multihop 2
 neighbor 102.102.102.102 update-source Loopback103
 neighbor 104.104.104.104 remote-as 104
 neighbor 104.104.104.104 ebgp-multihop 2
 neighbor 104.104.104.104 update-source Loopback103
 no auto-summary
!        
ip route 102.102.102.102 255.255.255.255 123.1.1.1
ip route 104.104.104.104 255.255.255.255 134.1.1.2
!

R104:

!
interface Loopback40
 ip address 192.168.40.40 255.255.255.255
!
interface Loopback41
 ip address 192.168.41.41 255.255.255.255
!
interface Loopback42
 ip address 192.168.42.42 255.255.255.255
!
interface Loopback43
 ip address 192.168.43.43 255.255.255.255
!
interface Loopback44
 ip address 192.168.44.44 255.255.255.255
!
interface Loopback104
 ip address 104.104.104.104 255.255.255.255
!
router bgp 104
 no synchronization
 bgp log-neighbor-changes
 network 192.168.40.40 mask 255.255.255.255
 network 192.168.41.41 mask 255.255.255.255
 network 192.168.42.42 mask 255.255.255.255
 network 192.168.43.43 mask 255.255.255.255
 network 192.168.44.44 mask 255.255.255.255
 neighbor 101.101.101.101 remote-as 101
 neighbor 101.101.101.101 password ccnp
 neighbor 101.101.101.101 ebgp-multihop 2
 neighbor 101.101.101.101 update-source Loopback104
 neighbor 103.103.103.103 remote-as 103
 neighbor 103.103.103.103 ebgp-multihop 2
 neighbor 103.103.103.103 update-source Loopback104
 no auto-summary
!
ip route 101.101.101.101 255.255.255.255 114.1.1.1
ip route 103.103.103.103 255.255.255.255 134.1.1.1
!

As a result, R1 learnes about the 192.168.x.x subnets on R104 from both ISPs and chooses the path via R101 due to the shortest AS_PATH:

R1#show ip bgp        
BGP table version is 6, 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
*  192.168.40.40/32 102.102.102.102                        0 102 103 104 i
*>                  101.101.101.101                        0 101 104 i
*  192.168.41.41/32 102.102.102.102                        0 102 103 104 i
*>                  101.101.101.101                        0 101 104 i
*  192.168.42.42/32 102.102.102.102                        0 102 103 104 i
*>                  101.101.101.101                        0 101 104 i
*  192.168.43.43/32 102.102.102.102                        0 102 103 104 i
*>                  101.101.101.101                        0 101 104 i
*  192.168.44.44/32 102.102.102.102                        0 102 103 104 i
*>                  101.101.101.101                        0 101 104 i

The best path algorithm logic is:
Step 0. The Next_Hop of each is reachable. (Otherwise the neighbors would not be up.)
Step 1. The Weight ties (both 0).
Step 2. The Local_Pref ties (unset, so no value is listed; defaults to 100).
Step 3. Neither route is locally injected; both are learned using BGP, so neither is better at this step.
Step 4. AS_Path length is shorter for the route through R101 (101.101.101.101).

Note: When IOS lists output in the variations of the show ip bgp command, the oldest route for each prefix is listed last, and the newest (most recently learned) is listed first.

A) Setting the BGP Administrative Weight Using a Route Map

The neighbor neighbor-ip route-map in BGP subcommand tells a router to apply the route map to all BGP Updates received from the listed neighbor. Such route maps always attempt to filter routes.
The router allows routes first matched in a permit clause and filters (discards) routes first matched with a deny clause.
BGP route maps can also be used to change the PAs of routes by using the set command.
(Although you can configure a set command in a route map deny clause, the set has no effect because the deny clause filters the route.)

The objective is that R1 should choose R102 instead of R101 to reach the 192.168.40.40 network. In order to obtain this result, we can set the weight for the route to be bigger, using a prefix list and a route-map:

R1(config)#ip prefix-list subnet40 permit 192.168.40.40/24 le 32
R1(config)#route-map set-weight-100 permit 10
R1(config-route-map)#match ip address prefix-list subnet40
R1(config-route-map)#set weight 100
R1(config)#route-map set-weight-100 permit 20

R1(config)#router bgp 100
R1(config-router)#neighbor 102.102.102.102 route-map set-weight-100 in


R1#clear ip bgp 102.102.102.102 soft

Checking the result on R1 - now R1 is choosing the path through R102 to reach 192.168.40.40/32:

R1#show ip bgp                      
BGP table version is 7, 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
*> 192.168.40.40/32 102.102.102.102                      100 102 103 104 i
*                   101.101.101.101                        0 101 104 i
*  192.168.41.41/32 102.102.102.102                        0 102 103 104 i
*>                  101.101.101.101                        0 101 104 i
*  192.168.42.42/32 102.102.102.102                        0 102 103 104 i
*>                  101.101.101.101                        0 101 104 i
*  192.168.43.43/32 102.102.102.102                        0 102 103 104 i
*>                  101.101.101.101                        0 101 104 i
*  192.168.44.44/32 102.102.102.102                        0 102 103 104 i
*>                  101.101.101.101                        0 101 104 i

Note: The displayed weight is 100 now.
Note: Paths that the router originates have a weight of 32,768 by default, and other paths have a weight of 0.

B) Setting Weight Using the neighbor weight Command

Alternatively, the weight can be set for all routes learned from a neighbor using the neighbor weight command.
Continuing the above example, let's set the weight for routes coming from R102 to 150, so that R1 will choose R102 as next-hop for all 192.168.x.x subnets.

R1(config)#router bgp 100
R1(config-router)#no neighbor 102.102.102.102 route-map set-weight-100 in
R1(config-router)#neighbor 102.102.102.102 weight 150

R1#clear ip bgp 102.102.102.102 soft

R1#show ip bgp
                      
BGP table version is 12, 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
*> 192.168.40.40/32 102.102.102.102                      150 102 103 104 i
*                   101.101.101.101                        0 101 104 i
*> 192.168.41.41/32 102.102.102.102                      150 102 103 104 i
*                   101.101.101.101                        0 101 104 i
*> 192.168.42.42/32 102.102.102.102                      150 102 103 104 i
*                   101.101.101.101                        0 101 104 i
*> 192.168.43.43/32 102.102.102.102                      150 102 103 104 i
*                   101.101.101.101                        0 101 104 i
*> 192.168.44.44/32 102.102.102.102                      150 102 103 104 i
*                   101.101.101.101                        0 101 104 i

Now, R1 has chosen R102 as next-hop for all routes, setting a weight of 150 for each of them, and thus ignoring the AS_PATH length (Step 1 vs Step 4 in the BGP best path algorithm).

No comments:

Post a Comment