ONLamp.com
oreilly.comSafari Books Online.Conferences.

advertisement


O'Reilly Book Excerpts: BGP

Traffic Engineering: Local Routing Policy

Related Reading

BGP
Building Reliable Networks with the Border Gateway Protocol
By Iljitsch van Beijnum

by Iljitsch van Beijnum

Editor's Note: In this second installment on Traffic Engineering, excerpted from O'Reilly's BGP, learn how to influence the BGP path-selection process.

Setting the Local Preference

The easiest and most effective way to influence the BGP path selection process is to adjust the Local Preference. This works well when certain routes are always better than others, for instance:

  • Routes over the main connection are preferred over routes that use a slower backup connection.
  • Routes from peering connections are preferred over routes from transit connections.
  • Routes directly to customers are preferred over external routes.

Example 6-2 shows part of a BGP configuration where the routes received from both peers receive different Local Preference values.

Example 6-2: Setting the Local Preference for all routes received from a BGP neighbor

!
router bgp 60055
 neighbor 192.0.254.17 remote-as 40077
 neighbor 192.0.254.17 route-map ispa-in in
 neighbor 219.2.19.1 remote-as 50066
 neighbor 219.2.19.1 route-map ispb-in in
!
route-map ispa-in permit 10
 set local-preference 90
!
route-map ispb-in permit 10
 set local-preference 110
!

In This Series

Traffic Engineering: Queuing, Traffic Shaping, and Policing
In the fifth and final installment in this series of excerpts on Traffic Engineering from O'Reilly's BGP, learn how to increase performance for certain protocols or sessions using special queuing strategies, traffic shaping, and rate limiting.

Traffic Engineering: Specific Routes
In this fourth installment on Traffic Engineering, excerpted from O'Reilly's BGP, learn how to balance incoming traffic by announcing more specific routes.

Traffic Engineering: Incoming Traffic
In this third installment on Traffic Engineering, excerpted from O'Reilly's BGP, learn how to balance inbound traffic.

Traffic Engineering: Finding the Right Route
In this first installment on Traffic Engineering, excerpted from O'Reilly's BGP, learn how to find the best route in a multihomed setup--the one that will take advantage of all available bandwidth.

The permit keyword in the route-map statement means matched routes will be permitted to enter the BGP table or be propagated to the neighbor; a deny route map will filter out all routes matching the match clause. The number 10 is the sequence number, used to apply the different route maps with the same tag in the right sequence. In this case, there is only one route map for each tag (ispa-in and ispb-in), so the sequence number doesn't do anything.

Since we want to match all routes, there is no need to supply a match clause for the route maps. Both route maps just use a set clause to set the Local Preference for every route that is received from the respective neighbor. This has the effect that if ISP B has a route to a destination, this route will always be preferred over the route ISP A has to the same destination. Routes from ISP A will be used only if there is no matching route over ISP B. This would be a good routing policy if traffic over ISP B is a lot cheaper than traffic over ISP A. Example 6-3 shows the BGP table after applying the route maps.

Example 6-3: Partial BGP table with different Local Preferences

BR1#show ip bgp
BGP table version is 619734, local router ID is  192.0.254.18
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
   Network     Next Hop      Metric LocPrf Path
*  7.7.0.0/19  192.0.254.17             90 40077 397 i
*>             219.2.19.1              110 50066 5703 397 i
*  8.8.0.0/16  192.0.254.17             90 40077 30021 i
*>             219.2.19.1              110 50066 30021 i
*  9.9.0.0/20  192.0.254.17             90 40077 5930 1070 i
*>             219.2.19.1              110 50066 1070 i

Under normal circumstances, the router would choose the route over AS 40077 for network 7.7.0.0/19 because the path over AS 50066 is longer. The higher Local Preference has precedence over the AS path length, however, so the route over ISP B is selected, as indicated with a > character. For 8.8.0.0/16, the AS path is the same length, so under other circumstances the decision would have come down to the tie- breaking rules. And for 9.9.0.0/20, the higher Local Preference doesn't really make a difference, because the route over AS 50066 has a shorter path anyway.

This policy works well as long as ISP B provides good connectivity to all destinations on the Net. But maybe ISP B peers with AS 30088 over a heavily congested connection, as shown in Figure 6-2.

Figure 6-2. The congestion between ISP B and AS 30088

In this case, routes that traverse AS 30088 should be avoided. This is accomplished in Example 6-4.

Example 6-4: Setting the Local Preference depending on AS path

!
ip as-path access-list 4 permit _30088_
ip as-path access-list 4 deny .*
!
route-map ispa-in permit 10
 set local-preference 90
!
route-map ispb-in permit 10
 match as-path 4
 set local-preference 80
!
route-map ispb-in permit 20
 set local-preference 110
!

The route map ispb-in permit 10 uses a match clause pointing to AS path access list 4 to find all routes with AS number 30088 in their AS path. The underscore characters before and after the AS number match a space, and the beginning or the end of the path. For a five-digit AS number, this doesn't make a difference, but the regular expression "3008" not only matches paths with AS number 3008 in it, but also with AS numbers such as 13008, 30080, 30081 and so on.

The routes received from ISP B that match AS path access list 4 are assigned a Local Preference value of 80. Routes not matching AS path access list 4 will be evaluated by the ispb-in permit 20 route map. There, they are always matched and assigned a Local Preference of 110.

Example 6-5 shows the result of applying these route maps for a route to a customer of AS 30088. Under normal circumstances, the second route would have been chosen because the path is shorter, but the modified Local Preference values make sure the first route is used.

Example 6-5: The result of Local Preference manipulation

BR1#show ip bgp 221.169.0.0
BGP routing table entry for 221.169.0.0/20, version 239188
Paths: (2 available, best #1)
  Not advertised to any peer
  40077 1800 30088 20099
    192.0.254.17 from 192.0.254.17 (192.0.254.17)
      Origin IGP, metric 20, localpref 90, valid, external, best, ref 2
  50066 30088 20099
    219.2.19.1 from 219.2.19.1 (219.2.13.237)
      Origin IGP, localpref 80, valid, external, ref 2

Pages: 1, 2

Next Pagearrow





Sponsored by: