Friday, August 1, 2014

Lab 11 - Bestpath Selection - Local Preference

This lab focuses on the local preference as-path attribute. This metric is second in line when evaluating best paths by BGP. Second to the cisco proprietary metric WEIGHT, the local preference is carried along with iBGP updates within an AS and is used to indicate to an AS a preferred exit for a particular prefix. Often times this is used in multi-ISP topologies as a traffic engineering tool to steer traffic towards a particular ISP.

Concepts covered:
-eBGP and iBGP peering
-BGP local-preference
-Route-maps and As-path access lists
-Regular Expressions

Tasks to complete lab:
-Establish eBGP peering between R1-ISP3 and R2-ISP2
-Establish a full mesh iBGP peering between R1,R2, and R3
-Configure traffic flow within AS 65123 such that packets destined for any
AS 10 prefixes prefer to exit using ISP2 when sourced from R3's loopback 0 address
-All other traffic should exit based on advertised path preference from the ISP
constraints:
-Do not modify any IGP settings
-Do not use static routes
-Only AS10 prefixes should be modified to prefer exiting via AS20.

Topology



GNS3 files: Link


Solution

Begin by establishing BGP peering per the task list. We should also include the next-hop-self command on the edge BGP speakers in our iBGP domain so that prefixes advertised into our iBGP has reachable next hops.

R1(config)#router bgp 65123
R1(config-router)#neighbor 192.168.31.3 remote-as 30
R1(config-router)#neighbor 192.168.123.2 remote-as 65123
R1(config-router)#neighbor 192.168.123.3 remote-as 65123
R1(config-router)#neighbor 192.168.123.2 next-hop-self
R1(config-router)#neighbor 192.168.123.3 next-hop-self

R2(config)#router bgp 65123
R2(config-router)#neighbor 192.168.22.22 remote-as 20
R2(config-router)#neighbor 192.168.123.1 remote-as 65123
R2(config-router)#neighbor 192.168.123.3 remote-as 65123
R2(config-router)#neighbor 192.168.123.1 next-hop-self
R2(config-router)#neighbor 192.168.123.3 next-hop-self

R3(config)#router bgp 65123
R3(config-router)#neighbor 192.168.123.1 remote-as 65123
R3(config-router)#neighbor 192.168.123.2 remote-as 65123

Next we use a route-map to modify the local preference to influence the best path decision for routes existing the 65123 AS. Local Preference is an indication to the AS of a preference to exit the AS. Its is advertised to other iBGP peers and a higher local preference is more prefered.

R2(config)#route-map SET_LOCAL_PREFERENCE permit 10
R2(config-router)#match as-path 1
R2(config-router)#set local-preference 101
R2(config)#route-map SET_LOCAL_PREFERENCE permit 9999

Then we apply our route map inbound to our ISP2 neighbor

R2(config)#router bgp 65123
R2(config-router)#neighbor 192.168.31.33 route-map SET_LOCAL_PREFERENCE in

When you apply the route map inbound and do a soft clearing of the BGP peering you get the following results.

R2(config)#do clear ip bgp * soft

R3#sh ip bgp | be Network
     Network          Next Hop            Metric LocPrf Weight Path
 *>i 172.16.0.0/24    192.168.123.2            0    101      0 20 10 i
 *>i 172.16.1.0/24    192.168.123.2            0    101      0 20 10 i
 *>i 172.16.2.0/24    192.168.123.2            0    101      0 20 10 i
 *>i 172.16.3.0/24    192.168.123.2            0    101      0 20 10 i
 *>i 172.16.4.0/24    192.168.123.2            0    101      0 20 10 i
 *>i 172.16.5.0/24    192.168.123.2            0    101      0 20 10 i
 *>i 172.16.6.0/24    192.168.123.2            0    101      0 20 10 i
 *>i 172.16.7.0/24    192.168.123.2            0    101      0 20 10 i

We have our preferred route and traffic is following the path that we selected.

R3#ping 172.16.2.1 source loopback 0
Pending 5, 100-byte ICMP Echos to 172.16.2.1, timeout is 2 seconds:
Packet sent with a source address of 3.3.3.3
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 52/79/116 ms

R3#traceroute 172.16.2.1 source loopback 0
Type escape sequence to abort.
Tracing the route to 172.16.2.1
VRF info: (vrf in name/id, vrf out name/id)
  1 192.168.123.2 20 msec 32 msec 24 msec
  2 192.168.22.22 60 msec 24 msec 88 msec
  3 192.168.12.1 88 msec *  116 msec

But notice that we have lost our alternative path through ISP3 on R3 in its BGP RIB and FIB tables. This is because R1 is receiving the prefix from R2 with the modified local preference and consequently that path is not the BEST path in R1's BGP RIB anymore. Since BGP only advertises best paths AND iBGP split horizon prevents re-advertisement of iBGP learned routes. R1 does not advertise the new R2 learned prefixes to R2 and R3. The results are to be expected and provide us the solution we wanted which is to force traffic for AS10's prefix out through ISP2.


Note: It should be noted that AS 65123 is technically a transit network for the 172.16.0.0/24 network given the current configuration. Normally you would want to filter things using a similar route filtering method as in this lab and an as-path access list with ^$ regex so that only locally originated routes are advertised to ISP2 and ISP4. But that will be the topic of another lab in the near future.

Sources:

BGP case studies:

BGP best path algorithm:



No comments:

Post a Comment