Jan 12, 2013

Best Practice for Using BGP Attributes to Modify Routing


       The BGP routing protocol has been known as one of the best routing protocols when there's any type of complex or even simple routing manipulation it has to occur. In many ways I like to consider it almost a kind of "all-terrain" routing protocol.   It functions great anywhere you go!  90% of the time it serves as a great IGP.  It was built to stand alone as an EGP, but when it comes to it's functionality, it really does do more than OSPF and EIGRP combined.

       In this post I'm going to briefly go through the BGP attributes and note the ones that are most commonly used when peering 2 EBGP neighbors for a multihomed setup as diagramed below.





These are the 8 BGP attributes as listed by Cisco.

W   Weight (Highest)
L   Local_Pref (Highest)
O   Originate (local originate)
AS  As_Path (shortest)
O   Origin Code (IGP < EGP < Incomplete)
M   MED (lowest)
P   Paths (External Paths preferred Over Internal)
R   Router ID (lowest)


Weight:
The Weight attribute only applies to Cisco routers and is local to the router, so other BGP peers along the path will not know about the attribute.  Since it's Cisco proprietary it's also not a popular selection as a route modifier.  The best bet is to stay away from it in a production environment.

Local Preference:
The local preference attribute is popular for route modifications since it is propagated within the entire AS.  It's definitely an attribute that is excellent to use when routes need to be followed deep within your AS.  This is a very popular attribute to modify for EBGP and IBGP routes and is highly recommended.

Originate:
The Originate attribute looks at how a route was learned locally.  Since this is not advertised within the local AS or to other AS's, it's best not to rely on this for route manipulation.

AS Path:
The AS Path attribute is one of my favorites because it is easy to set and follow.  It also gives you the ability to create filters within your network to avoid routes based upon an AS within the path.  I find this the easiest way to modify a route policy for external BGP sessions and I see it used most for multi homed EBGP sessions.  This is widely used for route modifications in multihomed BGP setups.

Origin Code:
The origin code is a way to pick the best path based upon a known route having been learned as an ibgp, ebgp, or incomplete route.  The modification of this is limited so it's not popular to use in a the real world for complex route manipulation.  This is not heavily depended on in production use.

MED or Metric:
The MED (or Metric) value allows for route modification by appending a value associated to the route, similar to how OSPF or EIGRP might append a metric.  It is very similar to the local preference, but not worth configuring if local preference can be depended on.

Paths:
The Path attribute selects a route that was learned via an ebgp neighbor over an ibgp neighbor.  This is standard for most BGP setups and isn't used for multihomed ebgp setups.  This will not do much for true route manipulation.

Router ID:
This attribute just says that if all the criteria above is equal amongst 2 paths, it will select the path with the peer that has the lowest router ID, or IP address.  This is a last resort route manipulating method.

Ultimately the way that I have seen route manipulation done in live multihomed BGP environments is to either adjust (a) the local preference, (b) the AS path, or (c) the MED.   If you focus on those you will get the biggest bang for your buck with route manipulation.  

I'm going to put together a sample of a route filter based upon each method so that you can see how these work exactly.

In the meantime I hope this helps.  Please leave any questions below.  Thanks for reading!

David

No comments:

Post a Comment